Search Results

Search found 461 results on 19 pages for 'parseint'.

Page 2/19 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Client side validation of multiple radio buttons groups

    - by absolutely-free
    This is my code: <html> <head> <title>scoreboard</title> <script> function calculate() { var sum=0; var total=0; for (var i=0; i < document.questions.group1.length; i++){ if (document.questions.group1[i].checked){ sum = parseInt(document.questions.group1[i].value) total = parseInt(total + sum);}} for (var i=0; i < document.questions.group2.length; i++){ if (document.questions.group2[i].checked){ sum = parseInt(document.questions.group2[i].value) total = parseInt(total + sum);}} for (var i=0; i < document.questions.group3.length; i++){ if (document.questions.group3[i].checked){ sum = parseInt(document.questions.group3[i].value) total = parseInt(total + sum);}} alert(total) } </script> </head> <body> <form name="questions"> A:<br> answer a1: <input type="radio" name="group1" value="0"> answer a2: <input type="radio" name="group1" value="1"> answer a3: <input type="radio" name="group1" value="2"> answer a4: <input type="radio" name="group1" value="3"><br> B:<br> answer b1: <input type="radio" name="group2" value="0"> answer b2: <input type="radio" name="group2" value="1"> answer b3: <input type="radio" name="group2" value="2"> answer b4: <input type="radio" name="group2" value="3"><br> C:<br> answer c1: <input type="radio" name="group3" value="0"> answer c2: <input type="radio" name="group3" value="1"> answer c3: <input type="radio" name="group3" value="2"> answer c4: <input type="radio" name="group3" value="3"><br><br> <input type="button" value="total" onclick="calculate()"> </form> </body> </html> How can I replace 'group[x]' in my code by a variable, so the three for-loops are replaced by one (because in reality there are a lot more questions and answers) ?

    Read the article

  • java phone number validation....

    - by user69514
    Here is my problem: Create a constructor for a telephone number given a string in the form xxx-xxx-xxxx or xxx-xxxx for a local number. Throw an exception if the format is not valid. So I was thinking to validate it using a regular expression, but I don't know if I'm doing it correctly. Also what kind of exception would I have to throw? Do I need to create my own exception? public TelephoneNumber(String aString){ if(isPhoneNumberValid(aString)==true){ StringTokenizer tokens = new StringTokenizer("-"); if(tokens.countTokens()==3){ areaCode = Integer.parseInt(tokens.nextToken()); exchangeCode = Integer.parseInt(tokens.nextToken()); number = Integer.parseInt(tokens.nextToken()); } else if(tokens.countTokens()==2){ exchangeCode = Integer.parseInt(tokens.nextToken()); number = Integer.parseInt(tokens.nextToken()); } else{ //throw an excemption here } } } public static boolean isPhoneNumberValid(String phoneNumber){ boolean isValid = false; //Initialize reg ex for phone number. String expression = "(\\d{3})(\\[-])(\\d{4})$"; CharSequence inputStr = phoneNumber; Pattern pattern = Pattern.compile(expression); Matcher matcher = pattern.matcher(inputStr); if(matcher.matches()){ isValid = true; } return isValid; } Hi sorry, yes this is homework. For this assignments the only valid format are xxx-xxx-xxxx and xxx-xxxx, all other formats (xxx)xxx-xxxx or xxxxxxxxxx are invalid in this case. I would like to know if my regular expression is correct

    Read the article

  • 2 dimensional arraylists in java

    - by Chris Maness
    So here's the deal I'm working on a project that requires me to have a 2 dimensional arraylist of 1 dimensional arrays. But every time I try to load in my data I get an error: Can't do this opperation because of bad input java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 On some of the inputs. I've got no idea where I'm going wrong on this one. A little help please? Source Code: import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner; import javax.swing.JOptionPane; import java.io.InputStream; public class Facebull { public static void main (String[] args) { if(args.length != 0){ load(args[0]); } else{ load("testFile"); } } public static void load(String fname) { int costOfMach = 0; ArrayList <Integer> finalMach = new ArrayList<Integer>(); ArrayList <ArrayList<int[]>>machines = new ArrayList<ArrayList<int[]>>(); Scanner inputFile = null; File f = new File(fname); if (f.exists ()) { try { inputFile = new Scanner (f); } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(null,"Can't find the file\n" + e); } int i = 0; while (inputFile.hasNext ( )) { String str = inputFile.nextLine ( ); String [ ] fields = str.split ("[\t ]"); System.out.println(str); if (!(fields[0].isEmpty() || fields[0].equals (""))){ fields[0] = fields[0].substring(1); fields[1] = fields[1].substring(1); fields[2] = fields[2].substring(1); try { //data to be inputed is 0 and 3 location of data is 1 and 2 int[] item = new int[2]; item[1] = Integer.parseInt(fields[0]); item[0] = Integer.parseInt(fields[3]); if(machines.size() < Integer.parseInt(fields[1])){ ArrayList<int[]> column = new ArrayList<int[]>(); machines.add (Integer.parseInt(fields[1])-1, column); System.out.println("we're in the if"); } machines.get(Integer.parseInt(fields[1])-1).add(Integer.parseInt(fields[2])-1, item); } //catches any exception catch (Exception e) { System.out.println("Can't do this opperation because of bad input \n" + e); } } } inputFile.close ( ); } System.out.print(machines); }//end load }

    Read the article

  • how can i resize font of div by resizing the div using jQuery?

    - by chirag
    Hello every one can any one help me out please? by using this code my font size is go beyound the size of parent div here $(divid).resizable({ maxHeight: parseInt(200), maxWidth: parseInt(180), resize: function(event, ui) { var width1 = parseInt(ui.element.css('width')); var height1 = parseInt(ui.element.css('height')); ui.element.css({'font-size': width1+'px'}); ui.element.css({'line-height': height1+'px'}); } }); where 'divid' is parent div where child div is present to fire resizing event of font, but i don't want font size go beyond the parent div, text is also not hidden.. can you please help me out???

    Read the article

  • Add Method to Built In Class

    - by Evorlor
    I am pretty sure this is not doable, but I will go ahead and cross my fingers and ask. I am trying to add a method to a built in class. I want this method to be callable by all of the built in class's subclasses. Specifically: I have a JButton, a JTextPane, and other JComponents. I want to be able to pass in a JDom Element instead of a Rectangle to setBounds(). My current solution is to extend each JComponent subclass with the desired methods, but that is a LOT of duplicate code. Is there a way I can write the following method just one time, and have it callable on all JComponent objects? Or is it required that I extend each subclass individually, and copy and paste the method below? public void setBounds(Element element) { this.setBounds(Integer.parseInt(element.getAttribute( "x").toString()), Integer.parseInt(element .getAttribute("y").toString()), Integer .parseInt(element.getAttribute("width").toString()), Integer.parseInt(element.getAttribute("height") .toString())); }

    Read the article

  • Js (+Mootools) - Why my script use over 60% of processor?

    - by Misiur
    On this site - LINK - i need to use 3 banner scrollers (2x vertical + 1x horizontal). I've tried to do it in flash, but then everyone web browsers shut down, or suspended. Now i want to do it in JS (i use mootools). All data come from MySQL. Here's the complete code (even if you don't know mootools, You should understand it) global $wpdb; $table = $wpdb->prefix.'part'; $sql = "SELECT * FROM $table"; $q = $wpdb->get_results($sql); $g = 0; if($wpdb->num_rows > 0) { ?> <script type="text/javascript"> window.addEvent('load', function(){ var totall = 0; var totalr = 0; $$('#leftCont0 .contElement').each(function(el){ var img = new Asset.image(el.getFirst('a').getFirst('img').get('src')); totall += img.height; }); $$('#rightCont0 .contElement').each(function(el){ var img = new Asset.image(el.getFirst('a').getFirst('img').get('src')); totalr += img.height; }); $$('.leftCont').each(function(el){ var h = parseInt(el.get('id').substr(8)); el.setStyle('top', h * totall); }); $$('.rightCont').each(function(el){ var h = parseInt(el.get('id').substr(9)); el.setStyle('top', h * totalr); }); var total = new Array(totall, totalr); move.periodical(30, null, total); }); function move(num, num2) { var h = 0; var da = false; var target = null; $$('.leftCont').each(function(el){ var act = el.getStyle('top'); var n = parseInt(act)+1; el.setStyle('top', n+"px"); if(el.getStyle('top') < h) { h = parseInt(el.getStyle('top')); alert(h); } if(parseInt(el.getStyle('top')) > 400) { da = true; target = el; } }); if(da) { var n = h - num; target.setStyle('top', n+'px'); } h = 0; da = false; $$('.rightCont').each(function(el){ var act = el.getStyle('top'); var n = parseInt(act)+1; el.setStyle('top', n+"px"); if(el.getStyle('top') < h) { h = parseInt(el.getStyle('top')); alert(h); } if(parseInt(el.getStyle('top')) > 400) { da = true; target = el; } }); if(da) { var n = h - num2; target.setStyle('top', n+'px'); } } </script> <?php $g = 0; $l = 0; $r = 0; $leftContent = array(); $rightContent = array(); $leftHeight = 0; $rightHeight = 0; foreach($q as $q) { if(($g % 2) == 0) { $leftContent[$l] = '<div class="contElement"> <a href="'.$q->aurl.'"><img src="'.$q->imgurl.'" alt="Partner" /></a> </div>'; $lHeight = getimagesize($q->imgurl); $leftHeight .= $lHeight[1]; $l++; } else { $rightContent[$r] = '<div class="contElement"> <a href="'.$q->aurl.'"><img src="'.$q->imgurl.'" alt="Partner" /></a> </div>'; $rHeight = getimagesize($q->imgurl); $rightHeight .= $rHeight[1]; $r++; } $g++; } $quantity = ceil(400 / $leftHeight) + 1; for($i = 0; $i < $quantity; $i++) { $str = ""; for($j = 0; $j < sizeof($leftContent); $j++) { $str .= $leftContent[$j]; } $leftContainer[$i] = '<div class="leftCont" id="leftCont'.$i.'">'.$str.'</div>'; } $quantity = ceil(400 / $rightHeight) + 1; for($i = 0; $i < $quantity; $i++) { $str = ""; for($j = 0; $j < sizeof($rightContent); $j++) { $str .= $rightContent[$j]; } $rightContainer[$i] = '<div class="rightCont" id="rightCont'.$i.'">'.$str.'</div>'; } ?> <div id="pcl"> <?php for($i = 0; $i < sizeof($leftContainer); $i++) { echo $leftContainer[$i]; } ?> </div> <div id="pcr"> <?php for($i = 0; $i < sizeof($rightContainer); $i++) { echo $rightContainer[$i]; } ?> </div> <?php }

    Read the article

  • android alarm not able to launch alarm activity

    - by user965830
    I am new to android programming and am trying to make this simple alarm app. I have my code written and it is compiled with no errors. The app runs in the emulator, that is the main activity asks the date and time, but when i click on the confirm button, it displays the message - "Unfortunately, Timer1 has stopped working." The code for my main activity is as follows: public void onClick(View v) { EditText date = (EditText) findViewById(R.id.editDate); EditText month = (EditText) findViewById(R.id.editMonth); EditText hour = (EditText) findViewById(R.id.editHour); EditText min = (EditText) findViewById(R.id.editMin); int dt = Integer.parseInt(date.getText().toString()); int mon = Integer.parseInt(month.getText().toString()); int hr = Integer.parseInt(hour.getText().toString()); int mnt = Integer.parseInt(min.getText().toString()); Intent myIntent = new Intent(MainActivity.this, AlarmActivity.class); pendingIntent = PendingIntent.getService(MainActivity.this, 0, myIntent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DATE, dt); calendar.set(Calendar.MONTH, mon); calendar.set(Calendar.HOUR, hr); calendar.set(Calendar.MINUTE, mnt); alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent); } I do not understand what all the errors in logcat mean, so i am posting them: 06-25 16:03:32.175: I/Process(566): Sending signal. PID: 566 SIG: 9 06-25 16:03:53.775: I/dalvikvm(612): threadid=3: reacting to signal 3 06-25 16:03:54.046: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt' 06-25 16:03:54.255: I/dalvikvm(612): threadid=3: reacting to signal 3 06-25 16:03:54.305: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt' 06-25 16:03:54.735: I/dalvikvm(612): threadid=3: reacting to signal 3 06-25 16:03:54.785: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt' 06-25 16:03:54.925: D/gralloc_goldfish(612): Emulator without GPU emulation detected. 06-25 16:05:09.605: D/AndroidRuntime(612): Shutting down VM 06-25 16:05:09.605: W/dalvikvm(612): threadid=1: thread exiting with uncaught exception (group=0x409c01f8) 06-25 16:05:09.685: E/AndroidRuntime(612): FATAL EXCEPTION: main 06-25 16:05:09.685: E/AndroidRuntime(612): java.lang.NumberFormatException: Invalid int: "android.widget.EditText@41030b40" 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.Integer.invalidInt(Integer.java:138) 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.Integer.parse(Integer.java:375) 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.Integer.parseInt(Integer.java:366) 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.Integer.parseInt(Integer.java:332) 06-25 16:05:09.685: E/AndroidRuntime(612): at com.kapymay.tversion1.MainActivity$1.onClick(MainActivity.java:34) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.view.View.performClick(View.java:3511) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.view.View$PerformClick.run(View.java:14105) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.os.Handler.handleCallback(Handler.java:605) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.os.Handler.dispatchMessage(Handler.java:92) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.os.Looper.loop(Looper.java:137) 06-25 16:05:09.685: E/AndroidRuntime(612): at android.app.ActivityThread.main(ActivityThread.java:4424) 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.reflect.Method.invokeNative(Native Method) 06-25 16:05:09.685: E/AndroidRuntime(612): at java.lang.reflect.Method.invoke(Method.java:511) 06-25 16:05:09.685: E/AndroidRuntime(612): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 06-25 16:05:09.685: E/AndroidRuntime(612): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 06-25 16:05:09.685: E/AndroidRuntime(612): at dalvik.system.NativeStart.main(Native Method) 06-25 16:05:10.445: I/dalvikvm(612): threadid=3: reacting to signal 3 06-25 16:05:10.575: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt'

    Read the article

  • My Jtable is blank

    - by mazin
    Hello my q is about a jtable that i have ,i fill it with components from a .txt ,I have a main (menu ) JFrame and by pressing a jbutton i want the jtable to pop out ! My problem is that my jtable is blank and it supposed to show some date !I would appreciated any help , Thanks. this is my ''reading'' class` public static void main(String[] args) { company Company=new company(); payFrame jframe=new payFrame(Company); jframe.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE); jframe.setSize(600,300); jframe.setVisible(true); readClass(); } //diavasma public static void readClass(){ ArrayList<Employee> emp =new ArrayList<Employee>() ; //Employee[] emp=new Employee[7]; //read from file try { int i=0; // int rowCounter; // int payments=0; String inputDocument = ("src/Employees.txt"); FileInputStream is = new FileInputStream(inputDocument); Reader iD = new InputStreamReader(is); BufferedReader buf = new BufferedReader(iD); String inputLine; while ((inputLine = buf.readLine()) != null) { String[] lineParts = inputLine.split(","); String email = (lineParts[7]); int EmpNo = Integer.parseInt(lineParts[0]); String type = lineParts[10]; int PostalCode = Integer.parseInt(lineParts[5]); int phone = Integer.parseInt(lineParts[6]); int DeptNo = (short) Integer.parseInt(lineParts[8]); double Salary; int card = (short) Integer.parseInt(lineParts[10]); int emptype = 0; int hours=Integer.parseInt(lineParts[11]); if (type.equals("FULL TIME")) { emptype = 1; } else if (type.equals("SELLER")) { emptype = 2; } else { emptype = 3; } /** * Creates employee instances depending on their type of employment * (fulltime=1, salesman=2, parttime=3) */ switch (emptype) { case 1: Salary = Double.parseDouble(lineParts[10]); emp.add(new FullTime(lineParts[1], lineParts[2], EmpNo, lineParts[3], lineParts[4], PostalCode, phone, email, DeptNo, card, Salary,hours, type)); i++; break; and this is my class where i make my Jtable and fill him public class company extends JFrame { private ArrayList<Employee> emp = new ArrayList<Employee>(); public void addEmployee(Employee emplo) { emp.add(emplo); } public ArrayList<Employee> getArray() { return emp; } public void getOption1() { ArrayList<Employee> employee = getArray(); JTable table = new JTable(); DefaultTableModel model = new DefaultTableModel(); table.setModel(model); model.setColumnIdentifiers(new String[]{"Code", "First Name", "Last Name", "Address", "City", "Postal Code", "Phone", "Email", "Dept Code", "Salary", "Time Card", "Hours"}); for (Employee current : employee) { model.addRow(new Object[]{current.getempCode(), current.getfirst(), current.getlast(), current.getaddress(), current.getcity(), current.getpostalCode(), current.gettelephone(), current.getemail(), current.getdep(), current.getsalary(), current.getcardcode(), current.getHours() }); } table.setPreferredScrollableViewportSize(new Dimension(500, 50)); table.setFillsViewportHeight(true); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); setVisible(true); table.revalidate();

    Read the article

  • where is this function getting its values from

    - by user295189
    I have the JS file below that I am working on and I have a need to know this specific function pg.getRecord_Response = function(){ } within the file. I need to know where are the values are coming from in this function for example arguments[0].responseText? I am new to javascript so any help will be much appreciated. Thanks var pg = new Object(); var da = document.body.all; // ===== - EXPRESS BUILD [REQUEST] - ===== // pg.expressBuild_Request = function(){ var n = new Object(); n.patientID = request.patientID; n.encounterID = request.encounterID; n.flowSheetID = request.flowSheetID; n.encounterPlan = request.encounterPlan; n.action = "/location/diagnosis/dsp_expressBuild.php"; n.target = popWinCenterScreen("/common/html/empty.htm", 619, 757, ""); myLocationDB.PostRequest(n); } // ===== - EXPRESS BUILD [RESPONSE] - ===== // pg.expressBuild_Response = function(){ pg.records.showHiddenRecords = 0; pg.loadRecords_Request(arguments.length ? arguments[0] : 0); } // ===== - GET RECORD [REQUEST] - ===== // pg.getRecord_Request = function(){ if(pg.records.lastSelected){ pg.workin(true); pg.record.recordID = pg.records.lastSelected.i; var n = new Object(); n.noheaders = 1; n.recordID = pg.record.recordID; myLocationDB.Ajax.Post("/location/diagnosis/get_record.php", n, pg.getRecord_Response); } else { pg.buttons.btnOpen.disable(true); } } // ===== - GET RECORD [RESPONSE] - ===== // pg.getRecord_Response = function(){ //alert(arguments[0].responseText); if(arguments.length && arguments[0].responseText){ alert(arguments[0].responseText); // Refresh PQRI grid when encounter context if(request.encounterID && window.parent.frames['main']){ window.parent.frames['main'].pg.loadQualityMeasureRequest(); } var rec = arguments[0].responseText.split(pg.delim + pg.delim); if(rec.length == 20){ // validate record values rec[0] = parseInt(rec[0]); rec[3] = parseInt(rec[3]); rec[5] = parseInt(rec[5]); rec[6] = parseInt(rec[6]); rec[7] = parseInt(rec[7]); rec[8] = parseInt(rec[8]); rec[9] = parseInt(rec[9]); rec[10] = parseInt(rec[10]); rec[11] = parseInt(rec[11]); rec[12] = parseInt(rec[12]); rec[15] = parseInt(rec[15]); // set record state pg.recordState = { recordID: pg.record.recordID, codeID: rec[0], description: rec[2], assessmentTypeID: rec[3], type: rec[4], onsetDateYear: rec[5], onsetDateMonth: rec[6], onsetDateDay: rec[7], onsetDateIsApproximate: rec[8], resolveDateYear: rec[9], resolveDateMonth: rec[10], resolveDateDay: rec[11], resolveDateIsApproximate: rec[12], commentsCount: rec[15], comments: rec[16] } // set record view pg.record.code.codeID = pg.recordState.codeID; pg.record.code.value = rec[1]; pg.record.description.value = rec[2]; for(var i=0; i<pg.record.type.options.length; i++){ if(pg.record.type.options[i].value == rec[4]){ pg.record.type.selectedIndex = i; break; } } for(var i=0; i<pg.record.assessmentType.options.length; i++){ if(pg.record.assessmentType.options[i].value == rec[3]){ pg.record.assessmentType.selectedIndex = i; break; } } if(rec[5]){ if(rec[6] && rec[7]){ pg.record.onsetDateType.selectedIndex = 0; pg.record.onsetDate.value = rec[6] + "/" + rec[7] + "/" + rec[5]; pg.record.onsetDate.format(); } else { pg.record.onsetDateType.selectedIndex = 1; pg.record.onsetDateMonth.selectedIndex = rec[6]; for(var i=0; i<pg.record.onsetDateYear.options.length; i++){ if(pg.record.onsetDateYear.options[i].value == rec[5]){ pg.record.onsetDateYear.selectedIndex = i; break; } } if(rec[8]) pg.record.chkOnsetDateIsApproximate.checked = true; } } else { pg.record.onsetDateType.selectedIndex = 2; } if(rec[9]){ if(rec[10] && rec[11]){ pg.record.resolveDateType.selectedIndex = 0; pg.record.resolveDate.value = rec[10] + "/" + rec[11] + "/" + rec[9]; pg.record.resolveDate.format(); } else { pg.record.resolveDateType.selectedIndex = 1; pg.record.resolveDateMonth.selectedIndex = rec[10]; for(var i=0; i<pg.record.resolveDateYear.options[i].length; i++){ if(pg.record.resolveDateYear.options.value == rec[9]){ pg.record.resolveDateYear.selectedIndex = i; break; } } if(rec[12]) pg.record.chkResolveDateIsApproximate.checked = true; } } else { pg.record.resolveDateType.selectedIndex = 2; } pg.record.lblCommentCount.innerHTML = rec[15]; pg.record.comments.value = rec[16]; pg.record.lblUpdatedBy.innerHTML = "* Last updated by " + rec[13] + " on " + rec[14]; pg.record.lblUpdatedBy.title = "Updated by: " + rec[13] + "\nUpdated on: " + rec[14]; pg.record.linkedNotes.setData(rec[18]); pg.record.linkedOrders.setData(rec[19]); pg.record.updates.setData(rec[17]); return; } } alert("An error occured while attempting to retrieve\ndetails for record #" + pg.record.recordID + ".\n\nPlease contact support if this problem persists.\nWe apologize for the inconvenience."); pg.hideRecordView(); } // ===== - HIDE COMMENTS VIEW - ===== // pg.hideCommentsView = function(){ pg.recordComments.style.left = ""; pg.recordComments.disabled = true; pg.recordComments.comments.value = ""; pg.record.disabled = false; pg.record.style.zIndex = 5500; } // ===== - HIDE code SEARCH - ===== // pg.hidecodeSearch = function(){ pg.codeSearch.style.left = ""; pg.codeSearch.disabled = true; pg.record.disabled = false; pg.record.style.zIndex = 5500; } // ===== - HIDE RECORD - ===== // pg.hideRecord = function(){ if(arguments.length){ pg.loadRecords_Request(); } else if(pg.records.lastSelected){ var n = new Object(); n.recordTypeID = 11; n.patientID = request.patientID; n.recordID = pg.records.lastSelected.i; n.action = "/location/hideRecord/dsp_hideRecord.php"; n.target = popWinCenterScreen("/common/html/empty.htm", 164, 476); myLocationDB.PostRequest(n); } } // ===== - HIDE RECORD VIEW - ===== // pg.hideRecordView = function(){ pg.record.style.left = ""; pg.record.disabled = true; // reset record grids pg.record.updates.state = "NO_RECORDS"; pg.record.linkedNotes.state = "NO_RECORDS"; pg.record.linkedOrders.state = "NO_RECORDS"; // reset linked record tabs pg.record.tabs[0].click(); pg.record.tabs[1].disable(true); pg.record.tabs[2].disable(true); pg.record.tabs[1].all[1].innerHTML = "Notes"; pg.record.tabs[2].all[1].innerHTML = "Orders"; // reset record state pg.recordState = null; // reset record view pg.record.recordID = 0; pg.record.code.value = ""; pg.record.code.codeID = 0; pg.record.description.value = ""; pg.record.type.selectedIndex = 0; pg.record.assessmentType.selectedIndex = 0; pg.record.onsetDateType.selectedIndex = 0; pg.record.chkOnsetDateIsApproximate.checked = false; pg.record.resolveDateType.selectedIndex = 0; pg.record.chkResolveDateIsApproximate.checked = false; pg.record.lblCommentCount.innerHTML = 0; pg.record.comments.value = ""; pg.record.lblUpdatedBy.innerHTML = ""; pg.record.lblUpdatedBy.title = ""; pg.record.updateComment = ""; pg.recordComments.comments.value = ""; pg.record.active = false; pg.codeSearch.newRecord = true; pg.blocker.className = ""; pg.workin(false); } // ===== - HIDE UPDATE VIEW - ===== // pg.hideUpdateView = function(){ pg.recordUpdate.style.left = ""; pg.recordUpdate.disabled = true; pg.recordUpdate.type.value = ""; pg.recordUpdate.onsetDate.value = ""; pg.recordUpdate.description.value = ""; pg.recordUpdate.resolveDate.value = ""; pg.recordUpdate.assessmentType.value = ""; pg.record.disabled = false; pg.record.btnViewUpdate.setState(); pg.record.style.zIndex = 5500; } // ===== - INIT - ===== // pg.init = function(){ var tab = 1; pg.delim = String.fromCharCode(127); pg.subDelim = String.fromCharCode(1); pg.blocker = da.blocker; pg.hourglass = da.hourglass; pg.pageContent = da.pageContent; pg.blocker.shim = da.blocker_shim; pg.activeTip = da.activeTip; pg.activeTip.anchor = null; pg.activeTip.shim = da.activeTip_shim; // PAGE TITLE pg.pageTitle = da.pageTitle; // TOTAL RECORDS pg.totalRecords = da.totalRecords[0]; // START RECORD pg.startRecord = da.startRecord[0]; pg.startRecord.onchange = function(){ pg.records.startRecord = this.value; pg.loadRecords_Request(); } // RECORD PANEL pg.recordPanel = myLocationDB.RecordPanel(pg.pageContent.all.recordPanel); for(var i=0; i<pg.recordPanel.buttons.length; i++){ if(pg.recordPanel.buttons[i].orderBy){ pg.recordPanel.buttons[i].onclick = pg.sortRecords; } } // RECORDS GRIDVIEW pg.records = pg.recordPanel.all.grid; alert(pg.recordPanel.all.grid); pg.records.sortOrder = "DESC"; pg.records.lastExpanded = null; pg.records.attachEvent("onrowclick", pg.record_click); pg.records.orderBy = pg.recordPanel.buttons[0].orderBy; pg.records.attachEvent("onrowmouseout", pg.record_mouseOut); pg.records.attachEvent("onrowdblclick", pg.getRecord_Request); pg.records.attachEvent("onrowmouseover", pg.record_mouseOver); pg.records.attachEvent("onstateready", pg.loadRecords_Response); // BUTTON - TOGGLE HIDDEN RECORDS pg.btnHiddenRecords = myLocationDB.Custom.ImageButton(3, 751, 19, 19, "/common/images/hide.gif", 1, 1, "", "", da.pageContent); pg.btnHiddenRecords.setTitle("Show hidden records"); pg.btnHiddenRecords.onclick = pg.toggleHiddenRecords; pg.btnHiddenRecords.setState = function(){ this.disable(!pg.records.totalHiddenRecords); } // code SEARCH SUBWIN pg.codeSearch = da.subWin_codeSearch; pg.codeSearch.newRecord = true; pg.codeSearch.searchType = "code"; pg.codeSearch.searchFavorites = true; pg.codeSearch.onkeydown = function(){ if(window.event && window.event.keyCode && window.event.keyCode == 113){ if(pg.codeSearch.searchType == "DESCRIPTION"){ pg.codeSearch.searchType = "code"; pg.codeSearch.lblSearchType.innerHTML = "ICD-9 Code"; } else { pg.codeSearch.searchType = "DESCRIPTION"; pg.codeSearch.lblSearchType.innerHTML = "Description"; } pg.searchcodes_Request(); } } // SEARCH TYPE pg.codeSearch.lblSearchType = pg.codeSearch.all.lblSearchType; // SEARCH STRING pg.codeSearch.searchString = pg.codeSearch.all.searchString; pg.codeSearch.searchString.tabIndex = 1; pg.codeSearch.searchString.onfocus = function(){ this.select(); } pg.codeSearch.searchString.onblur = function(){ this.value = this.value.trim(); } pg.codeSearch.searchString.onkeydown = function(){ if(window.event && window.event.keyCode && window.event.keyCode == 13){ pg.searchcodes_Request(); } } // -- "SEARCH" pg.codeSearch.btnSearch = pg.codeSearch.all.btnSearch; pg.codeSearch.btnSearch.tabIndex = 2; pg.codeSearch.btnSearch.disable = myLocationDB.Disable; pg.codeSearch.btnSearch.onclick = pg.searchcodes_Request; pg.codeSearch.btnSearch.baseTitle = "Search diagnosis codes"; pg.codeSearch.btnSearch.setState = function(){ pg.codeSearch.btnSearch.disable(pg.codeSearch.searchString.value.trim().length < 2); } pg.codeSearch.searchString.onkeyup = pg.codeSearch.btnSearch.setState; // START RECORD / TOTAL RECORDS pg.codeSearch.startRecord = pg.codeSearch.all.startRecord; pg.codeSearch.totalRecords = pg.codeSearch.all.totalRecords; pg.codeSearch.startRecord.onchange = function(){ pg.codeSearch.records.startRecord = this.value; pg.searchcodes_Request(); } // RECORD PANEL pg.codeSearch.recordPanel = myLocationDB.RecordPanel(pg.codeSearch.all.recordPanel); pg.codeSearch.recordPanel.buttons[0].onclick = pg.sortcodeResults; pg.codeSearch.recordPanel.buttons[1].onclick = pg.sortcodeResults; // DATA GRIDVIEW pg.codeSearch.records = pg.codeSearch.all.grid; pg.codeSearch.records.orderBy = "code"; pg.codeSearch.records.attachEvent("onrowdblclick", pg.updatecode); pg.codeSearch.records.attachEvent("onstateready", pg.searchcodes_Response); // BUTTON - "CANCEL" pg.codeSearch.btnCancel = pg.codeSearch.all.btnCancel; pg.codeSearch.btnCancel.tabIndex = 4; pg.codeSearch.btnCancel.onclick = pg.hidecodeSearch; pg.codeSearch.btnCancel.title = "Close this search area"; // SEARCH FAVORITES / ALL pg.codeSearch.optSearch = myLocationDB.InputButton(pg.codeSearch.all.optSearch); pg.codeSearch.optSearch[0].onclick = function(){ if(pg.codeSearch.searchFavorites){ pg.codeSearch.searchString.focus(); } else { pg.codeSearch.searchFavorites = true; pg.searchcodes_Request(); } } pg.codeSearch.optSearch[1].onclick = function(){ if(pg.codeSearch.searchFavorites){ pg.codeSearch.searchFavorites = false; pg.searchcodes_Request(); } else { pg.codeSearch.searchString.focus(); } } // -- "USE SELECTED" pg.codeSearch.btnUseSelected = pg.codeSearch.all.btnUseSelected; pg.codeSearch.btnUseSelected.tabIndex = 3; pg.codeSearch.btnUseSelected.onclick = pg.updatecode; pg.codeSearch.btnUseSelected.disable = myLocationDB.Disable; pg.codeSearch.btnUseSelected.baseTitle = "Use the selected diagnosis code"; pg.codeSearch.btnUseSelected.setState = function(){ pg.codeSearch.btnUseSelected.disable(!pg.codeSearch.records.lastSelected); } pg.codeSearch.records.attachEvent("onrowclick", pg.codeSearch.btnUseSelected.setState); // RECORD STATE pg.recordState = null; // RECORD SUBWIN pg.record = da.subWin_record; pg.record.recordID = 0; pg.record.active = false; pg.record.updateComment = ""; // -- TABS pg.record.tabs = myLocationDB.TabCollection( pg.record.all.tab, function(){ if(pg.record.tabs[0].all[0].checked){ pg.record.btnOpen.style.display = "none"; pg.record.chkSelectAll.hitArea.style.display = "none"; pg.record.btnSave.style.display = "block"; pg.record.lblUpdatedBy.style.display = "block"; pg.record.pnlRecord_shim.style.display = "none"; } else { pg.record.pnlRecord_shim.style.display = "block"; pg.record.btnSave.style.display = "none"; pg.record.lblUpdatedBy.style.display = "none"; pg.record.btnOpen.setState(); pg.record.btnOpen.style.display = "block"; if(pg.record.tabs[2].all[0].checked){ pg.record.chkSelectAll.hitArea.style.display = "none"; //pg.record.btnViewLabs.setState(); //pg.record.btnViewLabs.style.display = "block"; } else { pg.record.chkSelectAll.setState(); pg.record.chkSelectAll.hitArea.style.display = "block"; //pg.record.btnViewLabs.style.display = "none"; } } } ); pg.record.tabs[1].disable(true); pg.record.tabs[2].disable(true); pg.record.pnlRecord_shim = pg.record.all.pnlRecord_shim; pg.record.code = pg.record.all.code; pg.record.code.codeID = 0; pg.record.code.tabIndex = -1; // -- CHANGE code pg.record.btnChangecode = myLocationDB.Custom.ImageButton(6, 107, 22, 22, "/common/images/edit.gif", 2, 2, "", "", pg.record.all.pnlRecord); pg.record.btnChangecode.tabIndex = 1; pg.record.btnChangecode.onclick = pg.showcodeSearch; pg.record.btnChangecode.title = "Change the diagnosis code for this problem"; pg.record.description = pg.record.all.description; pg.record.description.tabIndex = 2; pg.record.type = pg.record.all.type; pg.record.type.tabIndex = 3; pg.record.assessmentType = pg.record.all.assessmentType; pg.record.assessmentType.tabIndex = 9; // ONSET DATE pg.record.onsetDateType = pg.record.all.onsetDateType; pg.record.onsetDateType.tabIndex = 4; pg.record.onsetDateType.onchange = pg.record.onsetDateType.setState = function(){ switch(this.selectedIndex){ case 1: // PARTIAL pg.record.chkOnsetDateIsApproximate.disable(false); pg.record.onsetDate.style.visibility = "hidden"; pg.record.onsetDateUnknown.style.visibility = "hidden"; pg.record.onsetDate.datePicker.style.visibility = "hidden"; pg.record.onsetDateMonth.style.visibility = "visible"; pg.record.onsetDateYear.style.visibility = "visible"; break; case 2: // UNKNOWN pg.record.chkOnsetDateIsApproximate.disable(true); pg.record.onsetDate.style.visibility = "hidden"; pg.record.onsetDateYear.style.visibility = "hidden"; pg.record.onsetDateMonth.style.visibility = "hidden"; pg.record.onsetDate.datePicker.style.visibility = "hidden"; pg.record.onsetDateUnknown.style.visibility = "visible"; break; default: // "WHOLE" pg.record.chkOnsetDateIsApproximate.disable(true); pg.record.onsetDateMonth.style.visibility = "hidden"; pg.record.onsetDateYear.style.visibility = "hidden"; pg.record.onsetDateUnknown.style.visibility = "hidden"; pg.record.onsetDate.style.visibility = "visible"; pg.record.onsetDate.datePicker.style.visibility = "visible"; break; } } pg.record.onsetDate = myLocationDB.Custom.DateInput(30, 364, 80, pg.record.all.pnlRecord, 1, 1, 0, params.todayDate, 1); pg.record.onsetDate.tabIndex = 5; pg.record.onsetDate.style.textAlign = "LEFT"; pg.record.onsetDate.calendar.style.zIndex = 6000; pg.record.onsetDate.datePicker.style.left = "448px"; pg.record.onsetDate.setDateRange(params.birthDate, params.todayDate); pg.record.onsetDateYear = pg.record.all.onsetDateYear; pg.record.onsetDateYear.tabIndex = 6; pg.record.onsetDateMonth = pg.record.all.onsetDateMonth pg.record.onsetDateMonth.tabIndex = 7; pg.record.onsetDateUnknown = pg.record.all.onsetDateUnknown; pg.record.onsetDateUnknown.tabIndex = 8; pg.record.chkOnsetDateIsApproximate = myLocationDB.InputButton(pg.record.all.chkOnsetDateIsApproximate); pg.record.chkOnsetDateIsApproximate.setTitle("Onset date is approximate"); pg.record.chkOnsetDateIsApproximate.disable(true); // RESOLVE DATE pg.record.lblResolveDate = pg.record.all.lblResolveDate; pg.record.resolveDateType = pg.record.all.resolveDateType; pg.record.resolveDateType.tabIndex = 10; pg.record.resolveDateType.lastSelectedIndex = 0; pg.record.resolveDateType.setState = function(){ switch(this.selectedIndex){ case 1: // PARTIAL pg.record.chkResolveDateIsApproximate.disable(false); pg.record.resolveDate.style.visibility = "hidden"; pg.record.resolveDateUnknown.style.visibility = "hidden"; pg.record.resolveDate.datePicker.style.visibility = "hidden"; pg.record.resolveDateMonth.style.visibility = "visible"; pg.record.resolveDateYear.style.visibility = "visible"; break; case 2: // UNKNOWN pg.record.chkResolveDateIsApproximate.disable(true); pg.record.resolveDate.style.visibility = "hidden"; pg.record.resolveDateYear.style.visibility = "hidden"; pg.record.resolveDateMonth.style.visibility = "hidden"; pg.record.resolveDate.datePicker.style.visibility = "hidden"; pg.record.resolveDateUnknown.style.visibility = "visible"; break; default: // "WHOLE" pg.record.chkResolveDateIsApproximate.disable(true); pg.record.resolveDateMonth.style.visibility = "hidden"; pg.record.resolveDateYear.style.visibility = "hidden"; pg.record.resolveDateUnknown.style.visibility = "hidden"; pg.record.resolveDate.style.visibility = "visible"; pg.record.resolveDate.datePicker.style.visibility = "visible"; break; } } pg.record.resolveDateType.onchange = function(){ this.lastSelectedIndex = this.selectedIndex; this.setState(); } pg.record.resolveDate = myLocationDB.Custom.DateInput(55, 364, 80, pg.record.all.pnlRecord, 1, 1, 0, params.todayDate, 1); pg.record.resolveDate.tabIndex = 11; pg.record.resolveDate.style.textAlign = "LEFT"; pg.record.resolveDate.calendar.style.zIndex = 6000; pg.record.resolveDate.datePicker.style.left = "448px"; pg.record.resolveDate.setDateRange(params.birthDate, params.todayDate); pg.record.resolveDate.setState = function(){ if(pg.record.assessmentType.value == 15){ pg.record.chkResolveDateIsApproximate.disable(pg.record.resolveDateType.value != "PARTIAL"); pg.record.resolveDate.disabled = false; pg.record.lblResolveDate.disabled = false; pg.record.resolveDateType.selectedIndex = pg.record.resolveDateType.lastSelectedIndex; pg.record.resolveDateType.setState(); pg.record.resolveDate.datePicker.disable(false); pg.record.resolveDateType.disabled = false; pg.record.resolveDateYear.disabled = false; pg.record.resolveDateMonth.disabled = false; pg.record.resolveDateUnknown.disabled = false; } else { pg.record.resolveDate.datePicker.disable(true); pg.record.chkResolveDateIsApproximate.disable(true); pg.record.resolveDateType.selectedIndex = 2; pg.record.resolveDateType.setState(); pg.record.resolveDate.disabled = true; pg.record.lblResolveDate.disabled = true; pg.record.resolveDateType.disabled = true; pg.record.resolveDateYear.disabled = true; pg.record.resolveDateMonth.disabled = true; pg.record.resolveDateUnknown.disabled = true; } } pg.record.assessmentType.onchange = pg.record.resolveDate.setState; pg.record.resolveDateYear = pg.record.all.resolveDateYear; pg.record.resolveDateYear.tabIndex = 11; pg.record.resolveDateMonth = pg.record.all.resolveDateMonth pg.record.resolveDateMonth.tabIndex = 12; pg.record.resolveDateUnknown = pg.record.all.resolveDateUnknown; pg.record.resolveDateUnknown.tabIndex = 13; pg.record.chkResolveDateIsApproximate = myLocationDB.InputButton(pg.record.all.chkResolveDateIsApproximate); pg.record.chkResolveDateIsApproximate.setTitle("Resolve date is approximate"); pg.record.chkResolveDateIsApproximate.disable(true); // -- UPDATES pg.record.updates = pg.record.all.pnlUpdates.all.grid; pg.record.lblUpdateCount = pg.record.all.lblUpdateCount; pg.record.updates.attachEvent("onstateready", pg.showRecordView); pg.record.updates.attachEvent("onrowdblclick", pg.showUpdateView); // -- "VIEW SELECTED" pg.record.btnViewUpdate = myLocationDB.PanelButton(pg.record.all.btnViewUpdate); pg.record.btnViewUpdate.setTitle("View details for the selected problem update"); pg.record.btnViewUpdate.onclick = pg.showUpdateView; pg.record.btnViewUpdate.setState = function(){ pg.record.btnViewUpdate.disable(!pg.record.updates.lastSelected); } pg.record.updates.attachEvent("onrowclick", pg.record.btnViewUpdate.setState); // -- COMMENTS pg.record.comments = pg.record.all.comments; pg.record.pnlComments = pg.record.all.pnlComments; pg.record.lblCommentCount = pg.record.all.lblCommentCount; // -- UPDATE COMMENTS pg.record.btnUpdateComments = myLocationDB.PanelButton(pg.record.all.btnUpdateComments); pg.record.btnUpdateComments.onclick = pg.showCommentView; pg.record.btnUpdateComments.title = "Update this record's comments"; // -- LINKED NOTES pg.record.linkedNotes = pg.record.all.linkedNotes.all.grid; pg.record.linkedNotes.attachEvent("onrowclick", pg.linkedRecordClick); pg.record.linkedNotes.attachEvent("onrowdblclick", pg.openLinkedNote); pg.record.linkedNotes.attachEvent("onstateready", pg.setLinkedNotes_Count); // -- LINKED ORDERS pg.record.linkedOrders = pg.record.all.linkedOrders.all.grid; pg.record.linkedOrders.attachEvent("onrowclick", pg.linkedRecordClick); pg.record.linkedOrders.attachEvent("onrowdblclick", pg.openLinkedOrder); pg.record.linkedOrders.attachEvent("onstateready", pg.setLinkedOrders_Count); // -- "CLOSE" pg.record.btnClose = pg.record.all.btnClose; pg.record.btnClose.tabIndex = 15; pg.record.btnClose.onclick = pg.hideRecordView; pg.record.btnClose.title = "Close this record panel"; // -- LAST UPDATED BY pg.record.lblUpdatedBy = pg.record.all.lblUpdatedBy; // -- "SELECT ALL" pg.record.chkSelectAll = myLocationDB.InputButton(pg.record.all.chkSelectAll); pg.record.chkSelectAll.onclick = function(){ if(pg.record.tabs[1].all[0].checked){ if(pg.record.chkSelectAll.checked){ pg.record.linkedNotes.selectAll(); } else { pg.record.linkedNotes.deselectAll(); } } else { if(pg.record.chkSelectAll.checked){ pg.record.linkedOrders.selectAll(); } else { pg.record.linkedOrders.deselectAll(); } } pg.record.btnOpen.setState(); //pg.record.btnViewLabs.setState(); } pg.record.chkSelectAll.setState = function(){ if(pg.record.tabs[1].all[0].checked){ pg.record.chkSelectAll.checked = pg.record.linkedNotes.selectedRows.length == pg.record.linkedNotes.rows.length; } else { pg.record.chkSelectAll.checked = pg.record.linkedOrders.selectedRows.length == pg.record.linkedOrders.rows.length; } } // -- "OPEN SELECTED" pg.record.btnOpen = pg.record.all.btnOpenSelected; pg.record.btnOpen.tabIndex = 14; pg.record.btnOpen.disable = myLocationDB.Disable; pg.record.btnOpen.title = "Open the selected record"; pg.record.btnOpen.onclick = function(){ if(pg.record.tabs[1].all[0].checked){ pg.openLinkedNote(); } else if(pg.record.tabs[2].all[0].checked){ pg.openLinkedOrder(); } else { pg.record.btnOpen.disable(true); } } pg.record.btnOpen.setState = function(){ if(pg.record.tabs[1].all[0].checked){ pg.record.btnOpen.disable(!pg.record.linkedNotes.lastSelected); } else if(pg.record.tabs[2].all[0].checked){ pg.record.btnOpen.disable(pg.record.linkedOrders.selectedRows.length != 1); } else { pg.record.btnOpen.disable(true); } } // -- "SAVE" pg.record.btnSave = pg.record.all.btnSave; pg.record.btnSave.tabIndex = 14; pg.record.btnSave.onclick = pg.updateRecord_Request; pg.record.btnSave.title = "Save changes to this record"; // RECORD UPDATE SUBWIN pg.recordUpdate = da.subWin_update; pg.recordUpdate.lblUpdatedBy = pg.recordUpdate.all.lblUpdatedBy; pg.recordUpdate.lblUpdateDTS = pg.recordUpdate.all.lblUpdateDTS; pg.recordUpdate.type = pg.recordUpdate.all.type; pg.recordUpdate.onsetDate = pg.recordUpdate.all.onsetDate; pg.recordUpdate.description = pg.recordUpdate.all.description; pg.recordUpdate.resolveDate = pg.recordUpdate.all.resolveDate; pg.recordUpdate.assessmentType = pg.recordUpdate.all.assessmentType; // -- "CLOSE" pg.recordUpdate.btnClose = pg.recordUpdate.all.btnClose; pg.recordUpdate.btnClose.tabIndex = 1; pg.recordUpdate.btnClose.onclick = pg.hideUpdateView; pg.recordUpdate.btnClose.title = "Close this sub-window"; // COMMENTS SUBWIN pg.recordComments = da.subWin_comments; pg.recordComments.comments = pg.recordComments.all.updateComments; pg.recordComments.comment

    Read the article

  • How to call function that inside JQuery Plugin From outside the plugin?

    - by CaTz
    hi, i am using textarea elastic plugin JQuery. this is the plugin (function(jQuery){ jQuery.fn.extend({ elastic: function() { // We will create a div clone of the textarea // by copying these attributes from the textarea to the div. var mimics = [ 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'fontSize', 'lineHeight', 'fontFamily', 'width', 'fontWeight']; return this.each( function() { // Elastic only works on textareas if ( this.type != 'textarea' ) { return false; } var $textarea = jQuery(this), $twin = jQuery('<div />').css({'position': 'absolute','display':'none','word-wrap':'break-word'}), lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'), minheight = parseInt($textarea.css('height'),10) || lineHeight*3, maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE, goalheight = 0, i = 0; // Opera returns max-height of -1 if not set if (maxheight < 0) { maxheight = Number.MAX_VALUE; } // Append the twin to the DOM // We are going to meassure the height of this, not the textarea. $twin.appendTo($textarea.parent()); // Copy the essential styles (mimics) from the textarea to the twin var i = mimics.length; while(i--){ $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString())); } // Sets a given height and overflow state on the textarea function setHeightAndOverflow(height, overflow){ curratedHeight = Math.floor(parseInt(height,10)); if($textarea.height() != curratedHeight){ $textarea.css({'height': curratedHeight + 'px','overflow':overflow}); } } // This function will update the height of the textarea if necessary function update() { // Get curated content from the textarea. var textareaContent = $textarea.val().replace(/&/g,'&amp;').replace(/ /g, '&nbsp;').replace(/<|>/g, '&gt;').replace(/\n/g, '<br />'); var twinContent = $twin.html(); if(textareaContent+'&nbsp;' != twinContent){ // Add an extra white space so new rows are added when you are at the end of a row. $twin.html(textareaContent+'&nbsp;'); // Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height if(Math.abs($twin.height()+lineHeight/3 - $textarea.height()) > 3){ var goalheight = $twin.height()+lineHeight/3; if(goalheight >= maxheight) { setHeightAndOverflow(maxheight,'auto'); } else if(goalheight <= minheight) { setHeightAndOverflow(minheight,'hidden'); } else { setHeightAndOverflow(goalheight,'hidden'); } } } } // Hide scrollbars $textarea.css({'overflow':'hidden'}); // Update textarea size on keyup $textarea.keyup(function(){ update(); }); $textarea.focus(function(){ update(); }); // And this line is to catch the browser paste event $textarea.live('input paste',function(e){ setTimeout( update, 250); }); // Run update once when elastic is initialized update(); }); } }); })(jQuery); How can i call from the outside of the plugin to the update function that is inside?

    Read the article

  • Javascript returns Nan in IE, FF ok

    - by user350184
    im very new to javascript, and writing this script to add up a shopping cart and print out subtotals and totals. it works in FF but not in IE. this function is called by onclick of one of three select options with a value of 0-25. it is in a js file called in the head. what it does is get the selected values as variables, parseint them, adds and multiplies, and changes the innerHTML of the table to reflect the subtotals, and total. FF does it great, but IE gives Nan. ive tried rewriting it a number of different ways, and many translations still work in FF but not IE8. ive made sure the variables and form id's arent repeated. function gen_invoice() { var scount = parseInt(document.shopcart.studentcount.value, 10); var ycount = parseInt(document.shopcart.youthcount.value, 10); var fcount = parseInt(document.shopcart.facultycount.value, 10); //html output source is 3 selects like this, with diff ids and names: //<select name="studentcount" id="studentcount"> //<option onclick="gen_invoice()" value="0">0 </option></select> var cardcost = parseInt(document.shopcart.cardprice.value, 10); //cardcost comes from hidden input value: //<input type="hidden" id="cardprice" name="cardprice" value="25"> var totalsum = scount + ycount + fcount; var grandtotal = totalsum * cardcost; document.getElementById('s_price').innerHTML = scount * cardcost; document.getElementById('y_price').innerHTML = ycount * cardcost; document.getElementById('f_price').innerHTML = fcount * cardcost; document.getElementById('grand').innerHTML = grandtotal; //.... } ...after this there are 3 long loops for writing out some other forms, but they dont work in IE either because they depend on the selected values to be an integer. this part happens first and returns Nan, so im sure the problem is here somwhere. I have literally hit my head on the table over this. You can imagine how frustrating it is to be able to write the entire rest of the site beautifully, but then fail at adding 3 numbers together. help please!

    Read the article

  • javascript for (i = 0; i < XXX.length; i++) -> length question

    - by Fernando SBS
    for (m = 0; m < troopsCount.length; m++) { //FM_log(7,"i="+i+" m="+m); //FM_log(7,"tipoTropaPrioritaria[m] = "+tipoTropaPrioritaria[m]); //FM_log(7,"troopsCount[m] = "+troopsCount[m]); //FM_log(7,"availableTroops[m] = "+availableTroops[m]); if ((tipoTropaPrioritaria[m] == null || tipoTropaPrioritaria[m] == "undefined") || (troopsCount[m] == null || troopsCount[m] == "undefined") || (availableTroops[m] == null || availableTroops[m] == "undefined")) return "alternaTropas(): ERRO - tipoTropaPrioritaria[m] || troopsCount[m] || availableTroops[m] null ou undefined"; if ((parseInt(tipoTropaPrioritaria[m]) != 0) && (parseInt(troopsCount[m]) != 0)) { naoServe = true; break; } else { if ((parseInt(availableTroops[m])) < (parseInt(troopsCount[m]))) { naoServe = true; break; } else if (m < troopsCount.length) { naoServe = true; } else { //means m >= troopsCount.length naoServe = false; } } } my question is: the last statement else { //means m >= troopsCount.length naoServe = false; } will it ever be evaluated since for (m = 0; m < troopsCount.length; m++) ???

    Read the article

  • Check if a String is a double or an int?

    - by user69514
    I have a string for a Date in the form mm/dd, and I need to check if either the month or day was entered as a double public Date(String dateStr){ int slash = 0; //check slash is present try{ slash = dateStr.indexOf('/'); }catch(StringIndexOutOfBoundsException e){ error = "Invalid date format: " + dateStr; } //check if month is a number try{ month = Integer.parseInt(dateStr.substring(0, slash)); //day = Integer.parseInt(dateStr.substring(slash + 1, dateStr.length())); } catch(NumberFormatException e){ System.out.println("Invalid format for input string: " + dateStr.substring(0, slash)); } //check if day is a number try{ day = Integer.parseInt(dateStr.substring(slash + 1, dateStr.length())); } catch(NumberFormatException e){ System.out.println("Invalid format for input string: " + dateStr.substring(slash + 1, dateStr.length())); } //check if month was entered as a double }

    Read the article

  • Does form with enctype="multipart/form-data" cause problems accessing a hidden field

    - by Ankur
    I have created a hidden form element <form name="UploadImage" enctype="multipart/form-data" method="post" action="UploadImage"> <label> </label> <input name="imgUploadObjId" id="imgUploadObjId" value="52" type="hidden"> //rest of the form here </form> And I am trying to get the value with this line in a servlet (as I have done before): int objId = Integer.parseInt(request.getParameter("imgUploadObjId")); But I get this (line 33 is the line above): java.lang.NumberFormatException: null java.lang.Integer.parseInt(Unknown Source) java.lang.Integer.parseInt(Unknown Source) web.objects.UploadImage.doPost(UploadImage.java:33) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) Is there something different about a form with enctype="multipart/form-data"? Or can you see some other error.

    Read the article

  • Where can I find a jQuery color animation plugin?

    - by George Edison
    I need an up-to-date jQuery color animation plugin that works in IE 8. I tried using the one at http://plugins.jquery.com/project/color but it causes errors like "Invalid property value." in the following line of code from color.js: fx.elem.style[attr] = "rgb(" + [ Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0), Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0), Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0) ].join(",") + ")"; Where can I get something that works? By the way, I really hate IE, if that helps.

    Read the article

  • Ranking Part III

    - by PointsToShare
    © 2011 By: Dov Trietsch. All rights reserved   Ranking Part III In a previous blogs “Ranking an Introduction” and  “Ranking Part II” , you have already praised me in “Rank the Author” and learned how to create a new element on a page and how to place it where you need it. For this installment, I just added code to keep the number of votes (you vote by clicking one of the stars) and the total vote. Using these two, we can compute the average rating. It’s a small step, but its purpose is to show that we do not need a detailed history in order to compute the average. A running total is sufficient. Please note that once you close the game, you will lose your previous total. In real life, we persist the totals in the list itself. We also keep a list of actual votes, but its purpose is to prevent double votes. If a person has already voted, his user id is already on the list and our program will check for it and bar the person from voting again. This is coded in an event receiver, which is a SharePoint server piece of code. I will show you how to do this part in a subsequent blog. Again, go to the page and look at the code. The gist of it is here. avg, votes, and stars are global variables that I defined before. function sendRate(sel){//I hate long line so I created pieces of the message in their own vars            var s1 = "Your Rating Was: ";            var s2 = ".. ";            var s3 = "\nVotes = ";            var s4 = "\nTotal Stars = ";            var s5 = "\nAverage = ";            var s;            s = parseInt(sel.id.replace("_", '')); // Get the selected star number            votes = parseInt(votes) + 1;            stars = parseInt(stars) + s;            avg = parseFloat(stars) / parseFloat(votes);            alert(s1 + sel.id + s2 +sel.title + s3 + votes + s4 + stars + s5 + avg);} Click on the link to play and examine “Ranking with Stats” That’s all folks!

    Read the article

  • jQuery .append() not working in IE, Safari, and Chrome

    - by mkmcdonald
    So I'm using jQuery's AJAX function to read some XML for me and it's worked just fine. But now I'm trying to manipulate the display property of 4 different dynamically generated divs. The size and x/y of the divs are determined by the XML and are parsed through. My problem lies in the face that these divs either aren't being generated or just don't show up in IE, Safari, and Chrome. In Firefox and Opera, they do work. I'm using jQuery's .append() to create the divs and then the .css() functino to manipulate them. Looking in Chrome's developer tools, I am seeing that the css property being changed in the script is being overridden by the property in the stylesheet. Any fixes? $(document).ready(function(){ $.ajax({ type: "GET", url: "generate?test", dataType: "xml", success: function(xml) { $(xml).find('template').each(function(){ var portion = $(this).attr('portion'); var select; var name = $(this).find('$(this):first').text(); var mutability = $(this).attr('mutability'); var x = (parseInt($(this).find('x:first').text())*96)/72; var y = (parseInt($(this).find('y:first').text())*96)/72; switch(portion){ case "stub": select = $('#StubTemplates'); select.append(""+name+""); break; case "body": select = $('#BodyTemplates'); select.append(""+name+""); y = y + 90; break; } switch(mutability){ case "dynamic": var width = (parseInt($(this).find('width:first').text())*96)/72; var height = (parseInt($(this).find('height:first').text())*96)/72; var n = name; switch(portion){ case "stub": $('.ticket').append("") break; case "body": $('.ticket').append(""); break; } var top = $('#'+n).position().top; var left = parseInt($('#'+n).css('margin-left')); $('#'+n).css('top', (y+top)+"px"); $('#'+n).css('margin-left', (x+left)+"px"); $('#'+n).css('width', width+"px"); $('#'+n).css('height', height+"px"); break; case "static": var n = name; switch(portion){ case "stub": $('.ticket').append(""); break; case "body": $('.ticket').append(""); break; } break; } }); var stubActive = false; var bodyActive = false; $('#StubTemplates').find('.ddindent').mouseup(function(){ var tVal = $(this).val(); var tTitle = $(this).attr('title'); if(!stubActive){ $('.stubEditable').css('display', 'none'); $('#'+tVal).css('display', 'block'); stubActive = true; }else{ $('.stubEditable').css('display', 'none'); $('#'+tVal).css('display', 'block'); stubActive = false; } }); $('#StubTemplates').find('#stubTempNone').mouseup(function(){ $('.stubEditable').css('display', 'none'); }); $('#BodyTemplates').find('.ddindent').mouseup(function(){ var tVal = $(this).val(); var tTitle = $(this).attr('title'); if(!bodyActive){ $('.bodyEditable').css('display', 'none'); $('#'+tVal).css('display', 'block'); bodyActive = true; }else{ $('.bodyEditable').css('display', 'none'); $('#'+tVal).css('display', 'block'); bodyActive = false; } }); $('#BodyTemplates').find('#bodyTempNone').mouseup(function(){ $('.bodyEditable').css('display', 'none'); }); } }); });

    Read the article

  • Make my radio buttons become selected in Android

    - by NickTFried
    When I run this could and click on the dialog box my radiobuttons do not become selected like intended package edu.elon.cs.mobile; import edu.elon.cs.mobile.R; import edu.elon.cs.mobile.R.id; import edu.elon.cs.mobile.R.layout; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.text.Editable; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; import android.widget.TextView; import android.widget.Toast; public class PTCalculator extends Activity{ private RadioButton maleRadioButton; private RadioButton femaleRadioButton; private EditText ageEdit; private EditText pushUpsEdit; private EditText sitUpsEdit; private EditText mileMinEdit; private EditText mileSecEdit; private Button calculate; private TextView score; protected AlertDialog genderAlert; private int currScore; private int age; private int sitUps; private int runTime; private int pushUps; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pt); maleRadioButton = (RadioButton) findViewById(R.id.male); femaleRadioButton = (RadioButton) findViewById(R.id.female); ageEdit = (EditText) findViewById(R.id.ageEdit); pushUpsEdit = (EditText) findViewById(R.id.pushupEdit); sitUpsEdit = (EditText) findViewById(R.id.situpEdit); mileMinEdit = (EditText) findViewById(R.id.minEdit); mileSecEdit = (EditText) findViewById(R.id.secEdit); calculate = (Button) findViewById(R.id.calculateButton); calculate.setOnClickListener(calculateButtonListener); score = (TextView) findViewById(R.id.scoreView); genderAlert = makeGenderDialog().create(); } private OnClickListener calculateButtonListener = new OnClickListener() { @Override public void onClick(View arg0) { age = (Integer.parseInt(ageEdit.getText().toString())); pushUps = (Integer.parseInt(pushUpsEdit.getText().toString())); sitUps = (Integer.parseInt(sitUpsEdit.getText().toString())); int min = (Integer.parseInt(mileMinEdit.getText().toString())*60); int sec = (Integer.parseInt(mileSecEdit.getText().toString())); runTime = min + sec; if(maleRadioButton.isChecked()){ MalePTTest mPTTest = new MalePTTest(age, pushUps, sitUps, runTime); currScore = mPTTest.malePTScore(); score.setText((Integer.toString(currScore))); }else if(femaleRadioButton.isChecked()){ FemalePTTest fPTTest = new FemalePTTest(age, pushUps, sitUps, runTime); currScore = fPTTest.femalePTScore(); score.setText((Integer.toString(currScore))); }else genderAlert.show(); } }; public AlertDialog.Builder makeGenderDialog(){ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Select a Gender") .setCancelable(false) .setPositiveButton("Female", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { femaleRadioButton.setSelected(true); FemalePTTest fPTTest = new FemalePTTest(age, pushUps, sitUps, runTime); currScore = fPTTest.femalePTScore(); score.setText((Integer.toString(currScore))); } }) .setNegativeButton("Male", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { maleRadioButton.setSelected(true); MalePTTest mPTTest = new MalePTTest(age, pushUps, sitUps, runTime); currScore = mPTTest.malePTScore(); score.setText((Integer.toString(currScore))); } }); return builder; } } Any suggestions?

    Read the article

  • How can I add a previous button to this Jquery Content Slider?

    - by user1269988
    I did this nice tutorial for a Jquery Content Slider: http://brenelz.com/blog/build-a-content-slider-with-jquery/ Here is my test page: http://www.gregquinn.com/oneworld/brenez_slider_test.html But the Left button is hidden on the first slide and I do not want it to be. I don't know much about jquery but I tried to set the left button from opacity o to 100 or 1 and it didn't work the button showed up once but did not work. Does anyone know how to do this? Here is the code: (function($) { $.fn.ContentSlider = function(options) { var defaults = { leftBtn : 'images/panel_previous_btn.gif', rightBtn : 'images/panel_next_btn.gif', width : '900px', height : '400px', speed : 400, easing : 'easeOutQuad', textResize : false, IE_h2 : '26px', IE_p : '11px' } var defaultWidth = defaults.width; var o = $.extend(defaults, options); var w = parseInt(o.width); var n = this.children('.cs_wrapper').children('.cs_slider').children('.cs_article').length; var x = -1*w*n+w; // Minimum left value var p = parseInt(o.width)/parseInt(defaultWidth); var thisInstance = this.attr('id'); var inuse = false; // Prevents colliding animations function moveSlider(d, b) { var l = parseInt(b.siblings('.cs_wrapper').children('.cs_slider').css('left')); if(isNaN(l)) { var l = 0; } var m = (d=='left') ? l-w : l+w; if(m<=0&&m>=x) { b .siblings('.cs_wrapper') .children('.cs_slider') .animate({ 'left':m+'px' }, o.speed, o.easing, function() { inuse=false; }); if(b.attr('class')=='cs_leftBtn') { var thisBtn = $('#'+thisInstance+' .cs_leftBtn'); var otherBtn = $('#'+thisInstance+' .cs_rightBtn'); } else { var thisBtn = $('#'+thisInstance+' .cs_rightBtn'); var otherBtn = $('#'+thisInstance+' .cs_leftBtn'); } if(m==0||m==x) { thisBtn.animate({ 'opacity':'0' }, o.speed, o.easing, function() { thisBtn.hide(); }); } if(otherBtn.css('opacity')=='0') { otherBtn.show().animate({ 'opacity':'1' }, { duration:o.speed, easing:o.easing }); } } } function vCenterBtns(b) { // Safari and IE don't seem to like the CSS used to vertically center // the buttons, so we'll force it with this function var mid = parseInt(o.height)/2; b .find('.cs_leftBtn img').css({ 'top':mid+'px', 'padding':0 }).end() .find('.cs_rightBtn img').css({ 'top':mid+'px', 'padding':0 }); } return this.each(function() { $(this) // Set the width and height of the div to the defined size .css({ width:o.width, height:o.height }) // Add the buttons to move left and right .prepend('<a href="#" class="cs_leftBtn"><img src="'+o.leftBtn+'" /></a>') .append('<a href="#" class="cs_rightBtn"><img src="'+o.rightBtn+'" /></a>') // Dig down to the article div elements .find('.cs_article') // Set the width and height of the div to the defined size .css({ width:o.width, height:o.height }) .end() // Animate the entrance of the buttons .find('.cs_leftBtn') .css('opacity','0') .hide() .end() .find('.cs_rightBtn') .hide() .animate({ 'width':'show' }); // Resize the font to match the bounding box if(o.textResize===true) { var h2FontSize = $(this).find('h2').css('font-size'); var pFontSize = $(this).find('p').css('font-size'); $.each(jQuery.browser, function(i) { if($.browser.msie) { h2FontSize = o.IE_h2; pFontSize = o.IE_p; } }); $(this).find('h2').css({ 'font-size' : parseFloat(h2FontSize)*p+'px', 'margin-left' : '66%' }); $(this).find('p').css({ 'font-size' : parseFloat(pFontSize)*p+'px', 'margin-left' : '66%' }); $(this).find('.readmore').css({ 'font-size' : parseFloat(pFontSize)*p+'px', 'margin-left' : '66%' }); } // Store a copy of the button in a variable to pass to moveSlider() var leftBtn = $(this).children('.cs_leftBtn'); leftBtn.bind('click', function() { if(inuse===false) { inuse = true; moveSlider('right', leftBtn); } return false; // Keep the link from firing }); // Store a copy of the button in a variable to pass to moveSlider() var rightBtn = $(this).children('.cs_rightBtn'); rightBtn.bind('click', function() { if(inuse===false) { inuse=true; moveSlider('left', rightBtn); } return false; // Keep the link from firing }); }); } })(jQuery)

    Read the article

  • How to access string[] in xhtml page

    - by Kalpana
    I am having a simple string array in my bean as public String[] colors = new String[]{"red", "blue", "green"}; and trying to display these colors from my xhtml as but I am getting a java.lang.NumberFormatException: For input string: "colors" java.lang.NumberFormatException: For input string: "colors" at java.lang.NumberFormatException.forInputString(NumberFormatException. java:48) at java.lang.Integer.parseInt(Integer.java:447) at java.lang.Integer.parseInt(Integer.java:497) at javax.el.ListELResolver.coerce(ListELResolver.java:166) at javax.el.ListELResolver.getValue(ListELResolver.java:51) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)

    Read the article

  • Can this jQuery/Javascript functionality be replicated with PHP

    - by benhowdle89
    This is the code to grab tweets, but i need this in PHP, can anybody offer any insight? $(document).ready( function() { var url = "http://twitter.com/status/user_timeline/joebloggs.json?count=1&callback=?"; $.getJSON(url, function(data){ $.each(data, function(i, item) { $("#twitter-posts").append("<p>" + item.text.linkify() + " <span class='created_at'>" + relative_time(item.created_at) + " via " + item.source + "</span></p>"); }); }); }); String.prototype.linkify = function() { return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) { return m.link(m); }); }; function relative_time(time_value) { var values = time_value.split(" "); time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3]; var parsed_date = Date.parse(time_value); var relative_to = (arguments.length > 1) ? arguments[1] : new Date(); var delta = parseInt((relative_to.getTime() - parsed_date) / 1000); delta = delta + (relative_to.getTimezoneOffset() * 60); var r = ''; if (delta < 60) { r = 'a minute ago'; } else if(delta < 120) { r = 'couple of minutes ago'; } else if(delta < (45*60)) { r = (parseInt(delta / 60)).toString() + ' minutes ago'; } else if(delta < (90*60)) { r = 'an hour ago'; } else if(delta < (24*60*60)) { r = '' + (parseInt(delta / 3600)).toString() + ' hours ago'; } else if(delta < (48*60*60)) { r = '1 day ago'; } else { r = (parseInt(delta / 86400)).toString() + ' days ago'; } return r; } function twitter_callback () { return true; }

    Read the article

  • javascript div movement not working

    - by William
    For some reason I can't move this div at all. Can anyone help me out with why this won't work? <!DOCTYPE html> <html lang="en"> <head> <title>Move Div Test</title> <meta charset="utf-8" /> <link href="/bms/style.css" rel="stylesheet" /> <style> body { text-align: center; background-color: #ffffff;} #box { position: absolute; left: 610px; top: 80px; height: 50px; width: 50px; background-color: #ff0000;} </style> <script type="text/javascript"> document.onkeydown=function(event){keyDown(event)}; document.onkeyup=function(event){keyUp(event)}; var box = document.getElementById('box'); var speed = 5; var keys = new Array(256); var i = 0; for (i = 0;i <= 256; i++){ keys[i] = false; } function keyDown(event){ if(!event){ //for IE event = window.event; } keys[event.keyCode] = true; } function keyUp(event){ if(!event){ //for IE event = window.event; } keys[event.keyCode] = false; } function update(){ if(keys[37]) box.style.left = parseInt(box.style.left) - speed + "px"; if(keys[39]) box.style.left = parseInt(box.style.left) + speed + "px"; if(keys[38]) box.style.top = parseInt(box.style.top) - speed + "px"; if(keys[40]) box.style.top = parseInt(box.style.top) + speed + "px"; } setInterval('update();', 1000/60); </script> </head> <body> <div id="box">blah</div> </body> </html>

    Read the article

  • jqgrid modify data returned from ajax call before display in table

    - by user954211
    I have to display some data that I receive from the server as json object like this {"rowndx":"0","rows":"25","rowstotal":"100","rowsdata":[ ["00","DEVICE001","T0_IHOME","1","***","1","10"], ["01","DEVICE002","NO_DEVICE","1","***","1","10"], ["02","DEVICE003","NO_DEVICE","0","***","1","10"], ..... Before displaying the received data in a table I would like to make changes where necessary adding units to the numbers or replacing the numbers with words (eg 0 -OFF 1- ON) To do this I have associated at the ajax option "success" my encoding function. In this case, however, remains always visible the message "Loading ..." and no other action is permitted. I moved my re-encoding procedure to the "complete" ajax option and this time it seems to work. But I did not understand what was my mistake and I do not know if my procedure can work. This is my table ajax configuration url : "devtbl.json", mtype : "POST", datatype : "json", postData : ...... ajaxGridOptions: { type : 'post', contentType: 'application/json', async : false, complete : DEVparse_serverdata, error : function() { alert('Something bad happened. Stopping');}, }, jsonReader : { root : "tablerows", page : "currentpage", total : "totalpages", records : "totalrecords", cell : "", id : "0", userdata : "userdata", repeatitems : true }, and my coding function function DEVparse_serverdata(js , textStatus) { var jsontablereply = {} ; var rowsxpage_int = parseInt(UB.rowsxpage.DEVtable) ; var jsonreply = jQuery.parseJSON(js.responseText) ; jsontablereply.currentpage = "" + (1 + (parseInt(jsonreply.rowndx) / rowsxpage_int)); jsontablereply.totalpages = "" + parseInt((parseInt(jsonreply.rowstotal) + (rowsxpage_int-1)) / rowsxpage_int) ; jsontablereply.totalrecords = jsonreply.rowstotal; jsontablereply.tablerows = [] ; $.each(jsonreply.rowsdata, function(ndx, row) { var rowarray = [] ; rowarray[0] = row[0] ; rowarray[1] = row[1] ; rowarray[2] = row[2] ; rowarray[3] = row[3] ; rowarray[4] = row[4] ; switch (row[2]) { case "NO_DEVICE": rowarray[5] = "***" ; break ; case "T0_IHOME": rowarray[5] = "T=" + row[5] + "°C" ; break ; } jsontablereply.tablerows[ndx] = rowarray ; }) ; // each jQuery("#DEVtbl")[0].addJSONData(jsontablereply); } (I am a beginner with Jquery my coding style is poor)

    Read the article

  • Can we call methods of non-static classes without an object in Java?

    - by ask
    In Java, the wrapper class Integer has the static method parseInt() which is used like this: Integer.parseInt(). I thought only methods of static classes could be called like this (ie. Class.doMethod()). All non-static classes need objects to be instantiated to use their methods. I checked the API, and apparently Integer is declared as public final Integer - not static. Someone please help me understand this.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >