Search Results

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

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

  • Help with javascript form validation

    - by zac
    I am getting a headache with form validation and hoping that the kind folks here can give me a hand finishing this sucker up I have it basically working except the email validation is very simplistic (only alerts if it is blank but does not actually check it if is a valid email address) and I am relying on ugly alerts but would like to have it reveal a hidden error div instead of the alert. I have this all wrapped up with an age validation check too.. here are the important bits, minus the cookie scripts function checkAge() { valid = true; if ( document.emailForm.email.value== 0 ) { alert ( "Please enter your email." ); valid = false; } if ( document.emailForm.year.selectedIndex == 0 ) { alert ( "Please select your Age." ); valid = false; } var min_age = 13; var year = parseInt(document.forms["emailForm"]["year"].value); var month = parseInt(document.forms["emailForm"]["month"].value) - 1; var day = parseInt(document.forms["emailForm"]["day"].value); var theirDate = new Date((year + min_age), month, day); var today = new Date; if ( (today.getTime() - theirDate.getTime()) < 0) { var el = document.getElementById('emailBox'); if(el){ el.className += el.className ? ' youngOne' : 'youngOne'; } document.getElementById('emailBox').innerHTML = "<img src=\"emailSorry.gif\">" createCookie('age','not13',0) return false; } else { //this part doesnt work either document.getElementById('emailBox').innerHTML = "<img src=\"Success.gif\">" createCookie('age','over13',0) return valid; }; }; var x = readCookie('age'); window.onload=function(){ if (x=='null') { }; if (x=='over13') { }; if (x=='not13') { document.getElementById('emailBox').innerHTML = "<img src=\"emailSorry.gif\">"; }; } can someone please help me figure a better email validation for this bit: if ( document.emailForm.email.value== 0 ) { alert ( "Please enter your email." ); valid = false; } and how would I replace the alert with something that changes a class from hidden to visible? Something like? document.getElementById('emailError').style.display='block'

    Read the article

  • jquery not printing the image in IE 6

    - by pradeep
    if(count > 0){ for(var i= parseInt(start); i < parseInt(count); i++) { link ='<a href="/diabetes/ropimages/origpicdisplay.php?pid='+pid+'&rid='+i+'" target="_blank"><img src="/diabetes/ropimages/thumbpicdisplay.php?pid='+pid+'&rid='+i+'"/><a>&nbsp;&nbsp;'; if(i > start){ $("#content1").append(link);} else{ $("#content1").empty().html(link);} } } i use code like this. it does print images in FF but not in IE6 any solutions for this ?

    Read the article

  • how to make a BufferedReader in C

    - by peiska
    I am really new programming in C. How can i do the same in C, maybe in a more simple way then the one a do in Java. Each line of the input have to Integers: X e Y separated by a space. 12 1 12 3 23 4 9 3 InputStreamReader in = new InputStreamReader(System.in); BufferedReader buf = new BufferedReader(in); int n; int k; double sol; String line =""; line=buf.readLine(); while( line != null && !line.equals("")){ String data [] = line.split(" "); n = Integer.parseInt(data[0]); k = Integer.parseInt(data[1]); calculus (n,k); line = buf.readLine(); }

    Read the article

  • using javascript replace() to match the last occurance of a string

    - by Dave
    I'm building an 'add new row' function for product variations, and I'm struggling with the regex required to match the form attribute keys. So, I'm basically cloning rows, then incrementing the keys, like this (coffeescript): newrow = oldrow.find('select, input, textarea').each -> this.name = this.name.replace(/\[(\d+)\]/, (str, p1) -> "[" + (parseInt(p1, 10) + 1) + "]" ) this.id = this.id.replace(/\_(\d+)\_/, (str, p1) -> "_" + (parseInt(p1, 10) + 1) + "_" ) .end() This correctly increments a field with a name of product[variations][1][name], turning it into product[variations][2][name] BUT Each variation can have multiple options (eg, color can be red, blue, green), so I need to be able turn this product[variations][1][options][2][name] into product[variations][1][options][3][name], leaving the variation key alone. What regex do I need to match only the last occurrence of a key (the options key)?

    Read the article

  • Javascript & jquery : Unable to increment within a form

    - by Daniyal
    I got a simple increment function like this: $(function(){ $("#inc").click(function(){ var value = parseInt($(":text[name='ice_id']").val()) + 1; $(":text[name='ice_id']").val(value); }); $("#dec").click(function(){ var value = parseInt($(":text[name='ice_id']").val()) - 1; $(":text[name='ice_id']").val(value); }); }); the ice_id text field is embedded within a form <form id="masterSubmit" name="masterSubmit" action="" method="post"> <td><input id="ice_id" type="text" name="ice_id" size="16" maxlength="15"></td> </form> When I try now to increment , it successfully increments a number, but shows the following weird behavior: It 'refreshes' the site, so that the content of the text field is gone. This behavior disappears, if I comment out the form tags ...unfortunately the form tags are required for an AJAX-submit. Are there any ways to avoid this problem? Thanks in advance for any hints and best regards Daniyal

    Read the article

  • Why does my if statement always evaluate to true?

    - by Pobe
    I need to go through the months of the year and find out if the last day of the month is 28, 29, 30 or 31. My problem is that the first if statement always evaluates to true: MOIS_I = 31 if (mois == "Janvier" || "Mars" || "Mai" || "Juillet" || "Août" || "Octobre" || "Décembre" || "1" || "3" || "5" || "7" || "8" || "10" || "12" || "01" || "03" || "05" || "07" || "08") { window.alert("Le mois " + mois + " de l'année " + annee + " compte " + MOIS_I + " jours "); } Also, it seems like it is necessary to do if (mois == "Janver" || mois == "Février" || ... ) and so on, but I wanted to know if there was a better way to do it. Here is the full code: var mois, annee, test4, test100, test400; const MOIS_P = 30; const MOIS_I = 31; const FEV_NORM = 28; const FEV_BISSEX = 29; const TEST_4 = 4; const TEST_100 = 100; const TEST_400 = 400; mois = window.prompt("Entrez un mois de l'année", ""); annee = window.prompt("Entrez l'année de ce mois", ""); /* MOIS IMPAIRS */ if (mois == "Janvier" || "Mars" || "Mai" || "Juillet" || "Août" || "Octobre" || "Décembre" || "1" || "3" || "5" || "7" || "8" || "10" || "12" || "01" || "03" || "05" || "07" || "08") { window.alert("Le mois " + mois + " de l'année " + annee + " compte " + MOIS_I + " jours "); /* MOIS PAIRS */ } else if (mois == "Février" || "Avril" || "Juin" || "Septembre" || "Novembre" || "2" || "4" || "6" || "9" || "11" || "02" || "04" || "06" || "09") { if (mois == "Février") { test4 = parseInt(annee) % TEST_4; test100 = parseInt(annee) % TEST_100; test400 = parseInt(annee) % TEST_400; if (test4 == 0) { if (test100 != 0) { window.alert("Le mois " + mois + " de l'année " + annee + " compte " + FEV_BISSEX + " jours "); } else { window.alert("Le mois " + mois + " de l'année " + annee + " compte " + FEV_NORM + " jours "); } } else if (test400 == 0) { window.alert("Le mois " + mois + " de l'année " + annee + " compte " + FEV_BISSEX + " jours "); } else { window.alert("Le mois " + mois + " de l'année " + annee + " compte " + FEV_NORM + " jours "); } } else { window.alert("Le mois " + mois + " de l'année " + annee + " compte " + MOIS_P + " jours "); } } else { window.alert("Apocalypse!"); } TEST_4, TEST_100, TEST_400 are to test if the year is a leap year (which means february has 29 days instead of 28). Thank you!

    Read the article

  • Is it possible to replace a div element with jquery and update the dom?

    - by Scarface
    Hey guys quick question, I want to update the contents of a div with two new divs to take the place of the previous ones. Each new div has a unique id to take the place of the old ones. I then want any further update to use the ids of the new divs as their values instead of the original. Is this possible in Jquery? Thanks in advance for any assistance. var display_total=$(".display_total").attr("id"); var display_of_total=$(".display_of_total").attr("id"); var new_display_of_total=parseInt(display_of_total)+1; var new_display_total=parseInt(display_total)+1; $('.totalmessages').html('<div class="display_of_total" id="'+new_display_of_total+'">Displaying '+new_display_of_total+' of </div><div class="display_total" id="'+new_display_total+'">'+new_display_total+' messages...</div>');

    Read the article

  • Reading Inputs in Java - help

    - by peiska
    I am having a problem reading inputs, can anyone help me. Each line of the input have to Integers: X e Y separated by a space. 12 1 12 3 23 4 9 3 I am using this code in java but is not working, its only reading the first line can anyone help me? String []f; String line; Scanner in=new Scanner(System.in); while((line=in.nextLine())!=null){ f=line.split(" "); int X,Y; N=Integer.parseInt(f[0]); K=Integer.parseInt(f[1]); if(X<=40 && Y<=40) metohod(X,Y); linha=in.nextLine(); } }

    Read the article

  • Improved way to build nested array of unique values in javascript

    - by dualmon
    The setup: I have a nested html table structure that displays hierarchical data, and the individual rows can be hidden or shown by the user. Each row has a dom id that is comprised of the level number plus the primary key for the record type on that level. I have to have both, because each level is from a different database table, so the primary key alone is not unique in the dom. example: id="level-1-row-216" I am storing the levels and rows of the visible elements in a cookie, so that when the page reloads the same rows the user had open are can be shown automatically. I don't store the full map of dom ids, because I'm concerned about it getting too verbose, and I want to keep my cookie under 4Kb. So I convert the dom ids to a compact json object like this, with one property for each level, and a unique array of primary keys under each level: { 1:[231,432,7656], 2:[234,121], 3:[234,2], 4:[222,423], 5:[222] } With this structure stored in a cookie, I feed it to my show function and restore the user's previous disclosure state when the page loads. The area for improvement: I'm looking for better option for reducing my map of id selectors down to this compact format. Here is my function: function getVisibleIds(){ // example dom id: level-1-row-216-sub var ids = $("tr#[id^=level]:visible").map(function() { return this.id; }); var levels = {}; for(var i in ids ) { var id = ids[i]; if (typeof id == 'string'){ if (id.match(/^level/)){ // here we extract the number for level and row var level = id.replace(/.*(level-)(\d*)(.*)/, '$2'); var row = id.replace(/.*(row-)(\d*)(.*)/, '$2'); // *** Improvement here? *** // This works, but it seems klugy. In PHP it's one line (see below): if(levels.hasOwnProperty(level)){ if($.inArray(parseInt(row, 10) ,levels[level]) == -1){ levels[level].push(parseInt(row, 10)); } } else { levels[level] = [parseInt(row, 10)]; } } } } return levels; } If I were doing it in PHP, I'd build the compact array like this, but I can't figure it out in javascript: foreach($ids as $id) { if (/* the criteria */){ $level = /* extract it from $id */; $row = /* extract it from $id */; $levels[$level][$row]; } }

    Read the article

  • How do I make my applet turn the user's input into an integer and compare it to the computer's random number?

    - by Kitteran
    I'm in beginning programming and I don't fully understand applets yet. However, (with some help from internet tutorials) I was able to create an applet that plays a game of guess with the user. The applet compiles fine, but when it runs, this error message appears: "Exception in thread "main" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:470) at java.lang.Integer.parseInt(Integer.java:499) at Guess.createUserInterface(Guess.java:101) at Guess.<init>(Guess.java:31) at Guess.main(Guess.java:129)" I've tried moving the "userguess = Integer.parseInt( t1.getText() );" on line 101 to multiple places, but I still get the same error. Can anyone tell me what I'm doing wrong? The Code: // Creates the game GUI. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Guess extends JFrame{ private JLabel userinputJLabel; private JLabel lowerboundsJLabel; private JLabel upperboundsJLabel; private JLabel computertalkJLabel; private JButton guessJButton; private JPanel guessJPanel; static int computernum; int userguess; static void declare() { computernum = (int) (100 * Math.random()) + 1; //random number picked (1-100) } // no-argument constructor public Guess() { createUserInterface(); } // create and position GUI components private void createUserInterface() { // get content pane and set its layout Container contentPane = getContentPane(); contentPane.setLayout( null ); contentPane.setBackground( Color.white ); // set up userinputJLabel userinputJLabel = new JLabel(); userinputJLabel.setText( "Enter Guess Here -->" ); userinputJLabel.setBounds( 0, 65, 120, 50 ); userinputJLabel.setHorizontalAlignment( JLabel.CENTER ); userinputJLabel.setBackground( Color.white ); userinputJLabel.setOpaque( true ); contentPane.add( userinputJLabel ); // set up lowerboundsJLabel lowerboundsJLabel = new JLabel(); lowerboundsJLabel.setText( "Lower Bounds Of Guess = 1" ); lowerboundsJLabel.setBounds( 0, 0, 170, 50 ); lowerboundsJLabel.setHorizontalAlignment( JLabel.CENTER ); lowerboundsJLabel.setBackground( Color.white ); lowerboundsJLabel.setOpaque( true ); contentPane.add( lowerboundsJLabel ); // set up upperboundsJLabel upperboundsJLabel = new JLabel(); upperboundsJLabel.setText( "Upper Bounds Of Guess = 100" ); upperboundsJLabel.setBounds( 250, 0, 170, 50 ); upperboundsJLabel.setHorizontalAlignment( JLabel.CENTER ); upperboundsJLabel.setBackground( Color.white ); upperboundsJLabel.setOpaque( true ); contentPane.add( upperboundsJLabel ); // set up computertalkJLabel computertalkJLabel = new JLabel(); computertalkJLabel.setText( "Computer Says:" ); computertalkJLabel.setBounds( 0, 130, 100, 50 ); //format (x, y, width, height) computertalkJLabel.setHorizontalAlignment( JLabel.CENTER ); computertalkJLabel.setBackground( Color.white ); computertalkJLabel.setOpaque( true ); contentPane.add( computertalkJLabel ); //Set up guess jbutton guessJButton = new JButton(); guessJButton.setText( "Enter" ); guessJButton.setBounds( 250, 78, 100, 30 ); contentPane.add( guessJButton ); guessJButton.addActionListener( new ActionListener() // anonymous inner class { // event handler called when Guess button is pressed public void actionPerformed( ActionEvent event ) { guessActionPerformed( event ); } } // end anonymous inner class ); // end call to addActionListener // set properties of application's window setTitle( "Guess Game" ); // set title bar text setSize( 500, 500 ); // set window size setVisible( true ); // display window //create text field TextField t1 = new TextField(); // Blank text field for user input t1.setBounds( 135, 78, 100, 30 ); contentPane.add( t1 ); userguess = Integer.parseInt( t1.getText() ); //create section for computertalk Label computertalkLabel = new Label(""); computertalkLabel.setBounds( 115, 130, 300, 50); contentPane.add( computertalkLabel ); } // Display computer reactions to user guess private void guessActionPerformed( ActionEvent event ) { if (userguess > computernum) //if statements (computer's reactions to user guess) computertalkJLabel.setText( "Computer Says: Too High" ); else if (userguess < computernum) computertalkJLabel.setText( "Computer Says: Too Low" ); else if (userguess == computernum) computertalkJLabel.setText( "Computer Says:You Win!" ); else computertalkJLabel.setText( "Computer Says: Error" ); } // end method oneJButtonActionPerformed // end method createUserInterface // main method public static void main( String args[] ) { Guess application = new Guess(); application.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); } // end method main } // end class Phone

    Read the article

  • Splitting up input using regular expressions in Java

    - by Joe24
    I am making a program that lets a user input a chemical for example C9H11N02. When they enter that I want to split it up into pieces so I can have it like C9, H11, N, 02. When I have it like this I want to make changes to it so I can make it C10H12N203 and then put it back together. This is what I have done so far. using the regular expression I have used I can extract the integer value, but how would I go about get C10, H11 etc..? System.out.println("Enter Data"); Scanner k = new Scanner( System.in ); String input = k.nextLine(); String reg = "\\s\\s\\s"; String [] data; data = input.split( reg ); int m = Integer.parseInt( data[0] ); int n = Integer.parseInt( data[1] );

    Read the article

  • java.lang.NumberFormatException: unable to parse '' as integer one more time

    - by Quzziy
    I will take two numbers from user, but this number from EditText must be converted to int. I think it should be working, but I still have problem with compilation code in Android Studio. CatLog show error in line with: int wiek = Integer.parseInt(wiekEditText.getText().toString()); Below is my full Android code: public class MyActivity extends ActionBarActivity { int Wynik; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); int Tmax, RT; EditText wiekEditText = (EditText) findViewById(R.id.inWiek); EditText tspoczEditText = (EditText) findViewById(R.id.inTspocz); int wiek = Integer.parseInt(wiekEditText.getText().toString()); int tspocz = Integer.parseInt(tspoczEditText.getText().toString()); Tmax = 220 - wiek; RT = Tmax - tspocz; Wynik = 70*RT/100 + tspocz; final EditText tempWiekEdit = wiekEditText; TabHost tabHost = (TabHost) findViewById(R.id.tabHost); //Do TabHost'a z layoutu tabHost.setup(); TabHost.TabSpec tabSpec = tabHost.newTabSpec("Calc"); tabSpec.setContent(R.id.Calc); tabSpec.setIndicator("Calc"); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("Hints"); tabSpec.setContent(R.id.Hints); tabSpec.setIndicator("Hints"); tabHost.addTab(tabSpec); final Button Btn = (Button) findViewById(R.id.Btn); Btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(),"blablabla"+ "Wynik",Toast.LENGTH_SHORT).show(); } }); wiekEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { Btn.setEnabled(!(tempWiekEdit.getText().toString().trim().isEmpty())); } @Override public void afterTextChanged(Editable s) { } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.my, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }

    Read the article

  • mootools 1.11 .setHTML not working in IE

    - by moleculezz
    Hello, I am trying to make a form dynamic using mootools 1.11, for specific reasons I cannot upgrade atm. I'm trying to manipulate a select field to have dynamic options. This works in Firefox & Chrome but not IE8. Hope there's a fix for this. bits of the code: myOptions(hrs+1, 23, 'uur'); $('vertrektijd_uur').setHTML('<option value="">Kies uur</option>'+options_uur); $('vertrektijd_uur').addEvent('change', function() { hrsChanged = $('vertrektijd_uur').getValue(); hrsChanged = parseInt(hrsChanged); if(hrs+1 == hrsChanged) { myMinutes(parseInt(min)); myOptions(minChanged, 55, 'min'); $('vertrektijd_min').setHTML('<option value="">Kies minuten</option>'+options_min); } else { myOptions(0, 55, 'min'); $('vertrektijd_min').setHTML('<option value="">Kies minuten</option>'+options_min); } });

    Read the article

  • How to convert string to integer?

    - by user1260584
    So I'm having a hard time with my situation and need some advice. I'm trying to convert my two Strings that I have into integers, so that I can use them in math equations. Here is what I tried, however it brings me an error in the app. ' equals.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { // TODO Auto-generated method stub num1 = edit.getText().toString(); num2 = edit.getText().toString(); int first = Integer.parseInt(num1); int second = Integer.parseInt(num2); edit.setText(first + second); } }); Is there something that I am doing wrong? Thank you for any help. EDIT: Yes this is Java. num1 and num2 are strings that I have previously named. What do you mean by trim?

    Read the article

  • How to display values from another website to an new html page?

    - by user3098728
    How to display the value in a new html file from different website? This an example field of values that need to display into new html file and I want to display the said values in the input box (Contract ID) of this page JSFiddle. I have 2 JS code that would display that values, but unfortunately its not working and I dont know how to display that value in html input box. Please help me. Thank you I want to display the said value in this input box: Here the JS file to read the values: function scanLapVerification() { try { var page_title = "Title"; var el = getElement(document, "class", "view-operator-verification-title", ""); if (!el || el.length == 0) return; if (el[0].innerText != page_title) return; var page_title = ''; var el = getElement(document, "class", "workflowActivityDetailPanel", ""); if (el && el.length > 0) { var eltr = getElement(el[0], "tag", "tr", ""); if (eltr && eltr.length > 0) { //Read Contract ID var contractId = { CI: { id: null } }; var con_id = null; for (var i = 0; i < eltr.length; i++) { tr_text = eltr[i].innerText; if (tr_text.substr(0, "Contract ID".length) == "Contract ID") con_id = "CI"; if (con_id && tr_text.substr(0, "Contract ID".length) == "Contract ID") { contractId[con_id].id = tr_text.substr("Contract ID".length + 1, tr_text.length - "Contract ID".length - 1); } } var contract_id = contractId.CI.id; return { content: "cid_check", con_id: con_id }; } return { status: "KO" }; } catch (e) { alert("Exception: scanLapVerification\n" + e.Description); return { status: "KO", message: e }; } }; And here's the 2nd JS that display to a new html page: function scanLapVerification() { chrome.tabs.sendRequest(tabLapVerification, { method: "scanLapVerification" }, function (response) { msgbox("receiveResponse: scanLapVerification " + jsonToString(response, "JSON")); //maintaining state in the background if (response.data.content == "cid_check") { //Popup window features var popupWindow = null; var name; var width = 550; var height = 200; var left = parseInt((screen.availWidth / 2) - (width / 2)); var top = parseInt((screen.availHeight / 2) - (height / 2)); var windowFeatures = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; //Input new address with popup window if (confirm("Does the client has new address?") == true) { popupWindow = window.open('/htmlname.htm', "title", windowFeatures + encodeURIComponent(response.data.contract_id)); popupWindow.focus(); } else { name = ""; } }); }

    Read the article

  • IntellIJ editor doesn't appear

    - by neveu
    I updated my IntellIJ install to the latest version (11.1.4) and now the Editor window doesn't appear. Double-clicking on the file, jump-to-source, nothing happens. No error message, it just doesn't appear. If I double-click on an xml layout file the preview window works, but no Editor window. Have installed and reinstalled; went back to an earlier version and it doesn't work there either. I'm at a loss. Any ideas? Update: Editor works if I create a new project. Update 2: idea.log file includes this (I don't know what ins.android.sdk.AndroidSdkData is): 2012-11-04 20:40:52,481 [ 2677] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/macros.xml file is null 2012-11-04 20:40:52,481 [ 2677] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/macros.xml 2012-11-04 20:40:52,482 [ 2678] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/quicklists.xml file is null 2012-11-04 20:40:52,482 [ 2678] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/quicklists.xml 2012-11-04 20:40:52,564 [ 2760] INFO - pl.stores.ApplicationStoreImpl - 76 application components initialized in 1285 ms 2012-11-04 20:40:52,575 [ 2771] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/customization.xml file is null 2012-11-04 20:40:52,575 [ 2771] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/customization.xml 2012-11-04 20:40:52,674 [ 2870] INFO - ij.openapi.wm.impl.IdeRootPane - App initialization took 3385 ms 2012-11-04 20:40:53,136 [ 3332] INFO - TestNG Runner - Create TestNG Template Configuration 2012-11-04 20:40:53,138 [ 3334] INFO - TestNG Runner - Create TestNG Template Configuration 2012-11-04 20:40:53,253 [ 3449] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/dynamic.xml file is null 2012-11-04 20:40:53,253 [ 3449] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/dynamic.xml 2012-11-04 20:40:53,280 [ 3476] INFO - api.vfs.impl.local.FileWatcher - 1 paths checked, 0 mapped, 202 mks 2012-11-04 20:40:53,366 [ 3562] INFO - ellij.project.impl.ProjectImpl - 137 project components initialized in 403 ms 2012-11-04 20:40:53,563 [ 3759] INFO - .module.impl.ModuleManagerImpl - 4 modules loaded in 197 ms 2012-11-04 20:40:53,625 [ 3821] INFO - api.vfs.impl.local.FileWatcher - 6 paths checked, 0 mapped, 150 mks 2012-11-04 20:40:54,187 [ 4383] INFO - .roots.impl.DirectoryIndexImpl - Directory index initialized in 271 ms, indexed 1611 directories 2012-11-04 20:40:54,207 [ 4403] INFO - pl.PushedFilePropertiesUpdater - File properties pushed in 18 ms 2012-11-04 20:40:54,237 [ 4433] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/plainTextFiles.xml file is null 2012-11-04 20:40:54,237 [ 4433] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/plainTextFiles.xml 2012-11-04 20:40:54,246 [ 4442] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/gant_config.xml file is null 2012-11-04 20:40:54,246 [ 4442] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/gant_config.xml 2012-11-04 20:40:54,253 [ 4449] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/gradle.xml file is null 2012-11-04 20:40:54,253 [ 4449] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/gradle.xml 2012-11-04 20:40:55,855 [ 6051] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/IntelliLang.xml file is null 2012-11-04 20:40:55,855 [ 6051] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/IntelliLang.xml 2012-11-04 20:40:56,995 [ 7191] INFO - leEditor.impl.EditorsSplitters - splitter 2012-11-04 20:40:56,996 [ 7192] INFO - leEditor.impl.EditorsSplitters - splitter 2012-11-04 20:40:57,233 [ 7429] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/codeStyleSettings.xml file is null 2012-11-04 20:40:57,233 [ 7429] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/codeStyleSettings.xml 2012-11-04 20:40:57,234 [ 7430] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/projectCodeStyle.xml file is null 2012-11-04 20:40:57,234 [ 7430] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/projectCodeStyle.xml 2012-11-04 20:40:58,145 [ 8341] INFO - indexing.UnindexedFilesUpdater - Indexable files iterated in 3911 ms 2012-11-04 20:40:58,146 [ 8342] INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 0 files to update 2012-11-04 20:40:58,146 [ 8342] INFO - indexing.UnindexedFilesUpdater - Unindexed files update done in 0 ms 2012-11-04 20:40:58,362 [ 8558] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/fileColors.xml file is null 2012-11-04 20:40:58,362 [ 8558] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/fileColors.xml 2012-11-04 20:41:00,420 [ 10616] INFO - ins.android.sdk.AndroidSdkData - For input string: "20.0.1" java.lang.NumberFormatException: For input string: "20.0.1" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:458) at java.lang.Integer.parseInt(Integer.java:499) at org.jetbrains.android.sdk.AndroidSdkData.parsePackageRevision(AndroidSdkData.java:86) at org.jetbrains.android.sdk.AndroidSdkData.<init>(AndroidSdkData.java:73) at org.jetbrains.android.sdk.AndroidSdkData.parse(AndroidSdkData.java:167) at org.jetbrains.android.sdk.AndroidPlatform.parse(AndroidPlatform.java:83) at org.jetbrains.android.sdk.AndroidSdkAdditionalData.getAndroidPlatform(AndroidSdkAdditionalData.java:119) at org.jetbrains.android.facet.AndroidFacet.addResourceFolderToSdkRootsIfNecessary(AndroidFacet.java:532) at org.jetbrains.android.facet.AndroidFacet.access$500(AndroidFacet.java:103) at org.jetbrains.android.facet.AndroidFacet$3.run(AndroidFacet.java:440) at com.intellij.ide.startup.impl.StartupManagerImpl$6.run(StartupManagerImpl.java:230) at com.intellij.ide.startup.impl.StartupManagerImpl.runActivities(StartupManagerImpl.java:203) at com.intellij.ide.startup.impl.StartupManagerImpl.access$100(StartupManagerImpl.java:41) at com.intellij.ide.startup.impl.StartupManagerImpl$4.run(StartupManagerImpl.java:170) at com.intellij.openapi.project.DumbServiceImpl.updateFinished(DumbServiceImpl.java:213) at com.intellij.openapi.project.DumbServiceImpl.access$1000(DumbServiceImpl.java:51) at com.intellij.openapi.project.DumbServiceImpl$IndexUpdateRunnable$1$3.run(DumbServiceImpl.java:363) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:702) at java.awt.EventQueue.access$400(EventQueue.java:82) at java.awt.EventQueue$2.run(EventQueue.java:663) at java.awt.EventQueue$2.run(EventQueue.java:661) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:672) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:699) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:538) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:420) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:378) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) 2012-11-04 20:41:00,459 [ 10655] INFO - ins.android.sdk.AndroidSdkData - For input string: "20.0.1" java.lang.NumberFormatException: For input string: "20.0.1" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:458) at java.lang.Integer.parseInt(Integer.java:499) at org.jetbrains.android.sdk.AndroidSdkData.parsePackageRevision(AndroidSdkData.java:86) at org.jetbrains.android.sdk.AndroidSdkData.<init>(AndroidSdkData.java:73) at org.jetbrains.android.sdk.AndroidSdkData.parse(AndroidSdkData.java:167) at org.jetbrains.android.sdk.AndroidPlatform.parse(AndroidPlatform.java:83) at org.jetbrains.android.sdk.AndroidSdkAdditionalData.getAndroidPlatform(AndroidSdkAdditionalData.java:119) at org.jetbrains.android.facet.AndroidFacet.addResourceFolderToSdkRootsIfNecessary(AndroidFacet.java:532) at org.jetbrains.android.facet.AndroidFacet.access$500(AndroidFacet.java:103) at org.jetbrains.android.facet.AndroidFacet$3.run(AndroidFacet.java:440) at com.intellij.ide.startup.impl.StartupManagerImpl$6.run(StartupManagerImpl.java:230) at com.intellij.ide.startup.impl.StartupManagerImpl.runActivities(StartupManagerImpl.java:203) at com.intellij.ide.startup.impl.StartupManagerImpl.access$100(StartupManagerImpl.java:41) at com.intellij.ide.startup.impl.StartupManagerImpl$4.run(StartupManagerImpl.java:170) at com.intellij.openapi.project.DumbServiceImpl.updateFinished(DumbServiceImpl.java:213) at com.intellij.openapi.project.DumbServiceImpl.access$1000(DumbServiceImpl.java:51) at com.intellij.openapi.project.DumbServiceImpl$IndexUpdateRunnable$1$3.run(DumbServiceImpl.java:363) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:702) at java.awt.EventQueue.access$400(EventQueue.java:82) at java.awt.EventQueue$2.run(EventQueue.java:663) at java.awt.EventQueue$2.run(EventQueue.java:661) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:672) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:699) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:538) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:420) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:378) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) 2012-11-04 20:41:01,305 [ 11501] INFO - tor.impl.FileEditorManagerImpl - Project opening took 8374 ms 2012-11-04 20:41:01,719 [ 11915] INFO - dom.attrs.AttributeDefinitions - Found tag with unknown parent: AndroidManifest.AndroidManifestCompatibleScreens 2012-11-04 20:41:07,522 [ 17718] INFO - roid.compiler.tools.AndroidApt - [/Users/neveu/Dev/android-sdk-macosx/platform-tools/aapt] [package] [-m] [--non-constant-id] [-J] [/private/var/folders/xb/hg6cdxt51rs8lylmmjw0fk8m0000gp/T/android_apt_autogeneration6157451500950136901tmp] [-M] [/Users/neveu/Dev/magic_android/3rdParty/facebook/AndroidManifest.xml] [-S] [/Users/neveu/Dev/magic_android/3rdParty/facebook/res] [-I] [/Users/neveu/Dev/android-sdk-macosx/platforms/android-14/android.jar] 2012-11-04 20:41:08,706 [ 18902] INFO - roid.compiler.tools.AndroidApt - [/Users/neveu/Dev/android-sdk-macosx/platform-tools/aapt] [package] [-m] [-J] [/private/var/folders/xb/hg6cdxt51rs8lylmmjw0fk8m0000gp/T/android_apt_autogeneration3143184519400737414tmp] [-M] [/Users/neveu/Dev/magic_android/AndroidManifest.xml] [-S] [/Users/neveu/Dev/magic_android/res] [-I] [/Users/neveu/Dev/android-sdk-macosx/platforms/android-15/android.jar] 2012-11-04 20:41:08,763 [ 18959] INFO - roid.compiler.tools.AndroidIdl - [/Users/neveu/Dev/android-sdk-macosx/platform-tools/aidl] [-p/Users/neveu/Dev/android-sdk-macosx/platforms/android-15/framework.aidl] [-I/Users/neveu/Dev/magic_android/magic/src] [-I/Users/neveu/Dev/magic_android/src] [-I/Users/neveu/Dev/magic_android/3rdParty/Tapjoy] [-I/Users/neveu/Dev/magic_android/gen] [/Users/neveu/Dev/magic_android/src/com/android/vending/billing/IMarketBillingService.aidl] [/Users/neveu/Dev/magic_android/gen/com/android/vending/billing/IMarketBillingService.java] 2012-11-04 20:41:14,004 [ 24200] INFO - dom.attrs.AttributeDefinitions - Found tag with unknown parent: AndroidManifest.AndroidManifestCompatibleScreens 2012-11-04 20:41:18,781 [ 28977] INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/cachedDictionary.xml file is null 2012-11-04 20:41:18,782 [ 28978] INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/cachedDictionary.xml

    Read the article

  • To display an album art from media store in android

    - by user1834724
    I'm not able to display album art from media store while listing albums,I'm getting following error Bad request for field slot 0,-1. numRows = 32, numColumns = 7 01-02 02:48:16.789: D/AndroidRuntime(4963): Shutting down VM 01-02 02:48:16.789: W/dalvikvm(4963): threadid=1: thread exiting with uncaught exception (group=0x4001e578) 01-02 02:48:16.804: E/AndroidRuntime(4963): FATAL EXCEPTION: main 01-02 02:48:16.804: E/AndroidRuntime(4963): java.lang.IllegalStateException: get field slot from row 0 col -1 failed Can anyone kindly help with this issue,Thanks in advance public class AlbumbsListActivity extends Activity { private ListAdapter albumListAdapter; private HashMap<Integer, Integer> albumInfo; private HashMap<Integer, Integer> albumListInfo; private HashMap<Integer, String> albumListTitleInfo; private String audioMediaId; private static final String TAG = "AlbumsListActivity"; Boolean showAlbumList = false; Boolean AlbumListTitle = false; ImageView album_art ; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.albums_list_layout); Cursor cursor; ContentResolver cr = getApplicationContext().getContentResolver(); if (getIntent().hasExtra(Util.ALBUM_ID)) { int albumId = getIntent().getIntExtra(Util.ALBUM_ID, Util.MINUS_ONE); String[] projection = new String[] { Albums._ID, Albums.ALBUM, Albums.ARTIST, Albums.ALBUM_ART, Albums.NUMBER_OF_SONGS }; String selection = null; String[] selectionArgs = null; String sortOrder = Media.ALBUM + " ASC"; cursor = cr.query(Albums.EXTERNAL_CONTENT_URI, projection, selection, selectionArgs, sortOrder); /* final String[] ccols = new String[] { //MediaStore.Audio.Albums., MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ALBUM, MediaStore.Audio.Albums.ARTIST, MediaStore.Audio.Albums.ALBUM_ART, MediaStore.Audio.Albums.NUMBER_OF_SONGS }; cursor = cr.query(MediaStore.Audio.Albums.getContentUri( "external"), ccols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);*/ showAlbumList = true; } else { String order = MediaStore.Audio.Albums.ALBUM + " ASC"; String where = MediaStore.Audio.Albums.ALBUM; cursor = managedQuery(Media.EXTERNAL_CONTENT_URI, DbUtil.projection, null, null, order); showAlbumList = false; } albumInfo = new HashMap<Integer, Integer>(); albumListInfo = new HashMap<Integer, Integer>(); ListView listView = (ListView) findViewById(R.id.mylist_album); listView.setFastScrollEnabled(true); listView.setOnItemLongClickListener(new ItemLongClickListener()); listView.setAdapter(new AlbumCursorAdapter(this, cursor, DbUtil.displayFields, DbUtil.displayViews,showAlbumList)); final Uri uri = MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI; final Cursor albumListCursor = cr.query(uri, DbUtil.Albumprojection, null, null, null); } private class AlbumCursorAdapter extends SimpleCursorAdapter implements SectionIndexer{ private final Context context; private final Cursor cursorValues; private Time musicTime; private Boolean isAlbumList; private MusicAlphabetIndexer mIndexer; private int mTitleIdx; public AlbumCursorAdapter(Context context, Cursor cursor, String[] from, int[] to,Boolean isAlbumList) { super(context, 0, cursor, from, to); this.context = context; this.cursorValues = cursor; //musicTime = new Time(); this.isAlbumList = isAlbumList; } String albumName=""; String artistName = ""; String numberofsongs = ""; long albumid; @Override public View getView(int position, View convertView, ViewGroup parent) { View rowView = convertView; if (rowView == null) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater .inflate(R.layout.row_album_layout, parent, false); } this.cursorValues.moveToPosition(position); String title = ""; String artistName = ""; String albumName = ""; int count; long albumid = 0; String songDuration = ""; if (isAlbumList) { albumInfo.put( position, Integer.parseInt(this.cursorValues.getString(this.cursorValues .getColumnIndex(MediaStore.Audio.Albums._ID)))); artistName = this.cursorValues .getString(this.cursorValues .getColumnIndex(MediaStore.Audio.Albums.ARTIST)); albumName = this.cursorValues .getString(this.cursorValues .getColumnIndex(MediaStore.Audio.Albums.ALBUM)); albumid=Integer.parseInt(this.cursorValues.getString(this.cursorValues .getColumnIndex(MediaStore.Audio.Albums.ALBUM_ID))); } else { albumInfo.put(position, Integer.parseInt(this.cursorValues .getString(this.cursorValues .getColumnIndex(MediaStore.Audio.Media._ID)))); artistName = this.cursorValues.getString(this.cursorValues .getColumnIndex(MediaStore.Audio.Media.ARTIST)); albumName = this.cursorValues.getString(this.cursorValues .getColumnIndex(MediaStore.Audio.Media.ALBUM)); albumid=Integer.parseInt(this.cursorValues.getString(this.cursorValues .getColumnIndex(MediaStore.Audio.Media.ALBUM_ID))); } //code for Alphabetical Indexer mTitleIdx = cursorValues.getColumnIndex(MediaStore.Audio.Media.ALBUM); mIndexer = new MusicAlphabetIndexer(cursorValues, mTitleIdx, getResources().getString(R.string.fast_scroll_alphabet)); //end TextView metaone = (TextView) rowView.findViewById(R.id.album_name); TextView metatwo = (TextView) rowView.findViewById(R.id.artist_name); ImageView metafour = (ImageView) rowView.findViewById(R.id.album_art); TextView metathree = (TextView) rowView .findViewById(R.id.songs_count); metaone.setText(albumName); metatwo.setText(artistName); (metafour)getAlbumArt(albumid); System.out.println("albumid----------"+albumid); metaThree.setText(DbUtil.makeTimeString(context, secs)); getAlbumArt(albumid); } TextView metaone = (TextView) rowView.findViewById(R.id.album_name); TextView metatwo = (TextView) rowView.findViewById(R.id.artist_name); album_art = (ImageView) rowView.findViewById(R.id.album_art); //TextView metathree = (TextView) rowView.findViewById(R.id.songs_count); metaone.setText(albumName); metatwo.setText(artistName); return rowView; } } String albumArtUri = ""; private void getAlbumArt(long albumid) { Uri uri=ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, albumid); System.out.println("hhhhhhhhhhh" + uri); Cursor cursor = getContentResolver().query( ContentUris.withAppendedId( MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, albumid), new String[] { MediaStore.Audio.AlbumColumns.ALBUM_ART }, null, null, null); if (cursor.moveToFirst()) { albumArtUri = cursor.getString(0); } System.out.println("kkkkkkkkkkkkkkkkkkk :" + albumArtUri); cursor.close(); if(albumArtUri != null){ Options opts = new Options(); opts.inJustDecodeBounds = true; Bitmap albumCoverBitmap = BitmapFactory.decodeFile(albumArtUri, opts); opts.inJustDecodeBounds = false; albumCoverBitmap = BitmapFactory.decodeFile(albumArtUri, opts); if(albumCoverBitmap != null) album_art.setImageBitmap(albumCoverBitmap); }else { // TODO: Options opts = new Options(); Bitmap albumCoverBitmap = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.albumart_mp_unknown_list, opts); if(albumCoverBitmap != null) album_art.setImageBitmap(albumCoverBitmap); } } } }

    Read the article

  • Avoid Jquery Plugin Conflict

    - by user1511579
    on the same page i'm using this plugin: $g=jQuery.noConflict(); $g(function() { /* number of fieldsets */ var fieldsetCount = $g('#formElem').children().length; /* current position of fieldset / navigation link */ var current = 1; /* sum and save the widths of each one of the fieldsets set the final sum as the total width of the steps element */ var stepsWidth = 0; var widths = new Array(); $g('#steps .step').each(function(i){ var $step = $g(this); widths[i]   = stepsWidth; stepsWidth += $step.width(); }); $g('#steps').width(stepsWidth); /* to avoid problems in IE, focus the first input of the form */ $g('#formElem').children(':first').find(':input:first').focus(); /* show the navigation bar */ $g('#navigation_form').show(); /* when clicking on a navigation link  the form slides to the corresponding fieldset */ $g('#navigation_form a').bind('click',function(e){ var $this = $g(this); var prev = current; $this.closest('ul').find('li').removeClass('selected'); $this.parent().addClass('selected'); /* we store the position of the link in the current variable */ current = $this.parent().index() + 1; /* animate / slide to the next or to the corresponding fieldset. The order of the links in the navigation is the order of the fieldsets. Also, after sliding, we trigger the focus on the first  input element of the new fieldset If we clicked on the last link (confirmation), then we validate all the fieldsets, otherwise we validate the previous one before the form slided */ $g('#steps').stop().animate({ marginLeft: '-' + widths[current-1] + 'px' },500,function(){ if(current == fieldsetCount) validateSteps(); else validateStep(prev); $g('#formElem').children(':nth-child('+ parseInt(current) +')').find(':input:first').focus(); }); e.preventDefault(); }); /* clicking on the tab (on the last input of each fieldset), makes the form slide to the next step */ $g('#formElem > fieldset').each(function(){ var $fieldset = $g(this); $fieldset.children(':last').find(':input').keydown(function(e){ if (e.which == 9){ $g('#navigation_form li:nth-child(' + (parseInt(current)+1) + ') a').click(); /* force the blur for validation */ $g(this).blur(); e.preventDefault(); } }); }); /* validates errors on all the fieldsets records if the Form has errors in $('#formElem').data() */ function validateSteps(){ var FormErrors = false; for(var i = 1; i < fieldsetCount; ++i){ var error = validateStep(i); if(error == -1) FormErrors = true; } $g('#formElem').data('errors',FormErrors); } /* validates one fieldset and returns -1 if errors found, or 1 if not */ function validateStep(step){ if(step == fieldsetCount) return; var error = 1; var hasError = false; $g('#formElem').children(':nth-child('+ parseInt(step) +')').find(':input:not(button)').each(function(){ var $this = $g(this); var valueLength = jQuery.trim($this.val()).length; if(valueLength == ''){ hasError = true; $this.css('background-color','#FFEDEF'); } else $this.css('background-color','#FFFFFF'); }); var $link = $g('#navigation_form li:nth-child(' + parseInt(step) + ') a'); $link.parent().find('.error,.checked').remove(); var valclass = 'checked'; if(hasError){ error = -1; valclass = 'error'; } $g('<span class="'+valclass+'"></span>').insertAfter($link); return error; } /* if there are errors don't allow the user to submit */ $g('#registerButton').bind('click',function(){ if($g('#formElem').data('errors')){ alert('Please correct the errors in the Form'); return false; } }); }); and this one: (function($){ $countCursos = 1; $countFormsA = 1; $countFormsB = 1; $.fn.addForms = function(idform){ var adicionar_curso = "<p>"+ " <label for='nome_curso'>Nome do Curso</label>"+ " <input id='nome_curso' name='nome_curso["+$countCursos+"]' type='text' />"+ " </p>"; var myform2 = "<table>"+ " <tr>"+ " <td>Field C</td>"+ " <td><input type='text' name='fieldc["+$countFormsA+"]'></td>"+ " <td>Field D ("+$countFormsA+"):</td>"+ " <td><textarea name='fieldd["+$countFormsA+"]'></textarea></td>"+ " <td><button>remove</button></td>"+ " </tr>"+ "</table>"; var myform3 = "<table>"+ " <tr>"+ " <td>Field C</td>"+ " <td><input type='text' name='fieldc["+$countFormsB+"]'></td>"+ " <td>Field D ("+$countFormsB+"):</td>"+ " <td><textarea name='fieldd["+$countFormsB+"]'></textarea></td>"+ " <td><button>remove</button></td>"+ " </tr>"+ "</table>"; if(idform=='novo_curso'){ alert(idform); adicionar_curso = $("<div>"+adicionar_curso+"</div>"); $("button", $(adicionar_curso)).click(function(){ $(this).parent().parent().remove(); }); $(this).append(adicionar_curso); $countCursos++; } if(idform=='mybutton1'){ alert(idform); myform2 = $("<div>"+myform2+"</div>"); $("button", $(myform2)).click(function(){ $(this).parent().parent().remove(); }); $(this).append(myform2); $countFormsA++; } if(idform=='mybutton2'){ alert(idform); myform3 = $("<div>"+myform3+"</div>"); $("button", $(myform3)).click(function(){ $(this).parent().parent().remove(); }); $(this).append(myform3); $countFormsB++; } }; })(jQuery); $(function(){ $("#mybutton1").bind("click", function(e){ e.preventDefault(); var idform=this.id; if($countFormsA<3){ $("#container1").addForms(idform); } }); }); $(function(){ $("#novo_curso").bind("click", function(e){ e.preventDefault(); var idform=this.id; alert(idform); if($countCursos<3){ $("#outro_curso").addForms(idform); } }); }); $(function(){ $("#mybutton2").bind("click", function(e){ e.preventDefault(); var idform=this.id; if($countFormsB<3){ $("#container2").addForms(idform); } }); }); My problem is the two are making conflict: I added previously the $g on the first to avoid conflict, but the truth is they don't work together, any hint how can i configure the second one to avoid this? Thanks in advance!

    Read the article

  • Form submit in javascript

    - by zac
    Hi been wrestling this form and the last step (actually submitting) has me scratching my head. What I have so far is the form: <form id="theForm" method='post' name="emailForm"> <table border="0" cellspacing="2"> <td>Email <span class="red">*</span></td><td><input type='text'class="validate[required,custom[email]]" size="30"></td></tr> <td>First Name:</td><td><input type='text' name='email[first]' id='first_name' size=30></td></tr> <tr height="30"> <td cellpadding="4">Last Name:</td><td><input type='text' name='email[last]' id='e_last_name' size=30> <td>Birthday</td> <td><select name='month' style='width:70px; margin-right: 10px'> <option value=''>Month</option> <option value="1">Jan</option> <option value="2">Feb</option> .... </select><select name='day' style='width:55px; margin-right: 10px'> <option value=''>Day</option> <option value="1">1</option> <option value="2">2</option> ... <option value="31">31</option> </select><select name='year' style='width:60px;' > <option value=''>Year</option> <option value="2007">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> ... </select> <input type='image' src='{{skin url=""}}images/email/signUpButt.gif' value='Submit' onClick="return checkAge()" /> <input type="hidden" id= "under13" name="under13" value="No"> and a script that checks the age and sets a cookie/changes display function checkAge() { var min_age = 13; var year = parseInt(document.forms["emailForm"]["year"].value); var month = parseInt(document.forms["emailForm"]["month"].value) - 1; var day = parseInt(document.forms["emailForm"]["day"].value); var theirDate = new Date((year + min_age), month, day); var today = new Date; if ( (today.getTime() - theirDate.getTime()) < 0) { var el = document.getElementById('emailBox'); if(el){ el.className += el.className ? ' youngOne' : 'youngOne'; } document.getElementById('emailBox').innerHTML = "<style type=\"text/css\">.formError {display:none}</style><p>Good Bye</p><p>You must be 13 years of age to sign up.</p>"; createCookie('age','not13',0) return false; } else { createCookie('age','over13',0) return true; }} that all seems to be working well.. just missing kind of a crucial step of actually submitting the form if it validates (if they pass the age question). So I am thinking that this will be wrapped in that script.. something in here : else { createCookie('age','over13',0) return true; } Can someone please help me figure out how I could handle this submit?

    Read the article

  • Get backreferences values and modificate these values

    - by roasted
    Could you please explain why im not able to get values of backreferences from a matched regex result and apply it some modification before effective replacement? The expected result is replacing for example string ".coord('X','Y')" by "X * Y". But if X to some value, divide this value by 2 and then use this new value in replacement. Here the code im currently testing: See /*>>1<<*/ & /*>>2<<*/ & /*>>3<<*/, this is where im stuck! I would like to be able to apply modification on backrefrences before replacement depending of backreferences values. Difference between /*>>2<<*/ & /*>>3<<*/ is just the self call anonymous function param The method /*>>2<<*/ is the expected working solution as i can understand it. But strangely, the replacement is not working correctly, replacing by alias $1 * $2 and not by value...? You can test the jsfiddle //string to test ".coord('125','255')" //array of regex pattern and replacement //just one for the example //for this example, pattern matching alphanumerics is not necessary (only decimal in coord) but keep it as it var regexes = [ //FORMAT is array of [PATTERN,REPLACEMENT] /*.coord("X","Y")*/ [/\.coord\(['"]([\w]+)['"],['"]?([\w:\.\\]+)['"]?\)/g, '$1 * $2'] ]; function testReg(inputText, $output) { //using regex for (var i = 0; i < regexes.length; i++) { /*==>**1**/ //this one works as usual but dont let me get backreferences values $output.val(inputText.replace(regexes[i][0], regexes[i][2])); /*==>**2**/ //this one should works as i understand it $output.val(inputText.replace(regexes[i][0], function(match, $1, $2, $3, $4) { $1 = checkReplace(match, $1, $2, $3, $4); //here want using $1 modified value in replacement return regexes[i][3]; })); /*==>**3**/ //this one is just a test by self call anonymous function $output.val(inputText.replace(regexes[i][0], function(match, $1, $2, $3, $4) { $1 = checkReplace(match, $1, $2, $3, $4); //here want using $1 modified value in replacement return regexes[i][4]; }())); inputText = $output.val(); } } function checkReplace(match, $1, $2, $3, $4) { console.log(match + ':::' + $1 + ':::' + $2 + ':::' + $3 + ':::' + $4); //HERE i should be able if lets say $1 > 200 divide it by 2 //then returning $1 value if($1 > 200) $1 = parseInt($1 / 2); return $1; }? Sure I'm missing something, but cannot get it! Thanks for your help, regards. EDIT WORKING METHOD: Finally get it, as mentionned by Eric: The key thing is that the function returns the literal text to substitute, not a string which is parsed for backreferences.?? JSFIDDLE So complete working code: (please note as pattern replacement will change for each matched pattern and optimisation of speed code is not an issue here, i will keep it like that) $('#btn').click(function() { testReg($('#input').val(), $('#output')); }); //array of regex pattern and replacement //just one for the example var regexes = [ //FORMAT is array of [PATTERN,REPLACEMENT] /*.coord("X","Y")*/ [/\.coord\(['"]([\w]+)['"],['"]?([\w:\.\\]+)['"]?\)/g, '$1 * $2'] ]; function testReg(inputText, $output) { //using regex for (var i = 0; i < regexes.length; i++) { $output.val(inputText.replace(regexes[i][0], function(match, $1, $2, $3, $4) { var checkedValues = checkReplace(match, $1, $2, $3, $4); $1 = checkedValues[0]; $2 = checkedValues[1]; regexes[i][1] = regexes[i][1].replace('$1', $1).replace('$2', $2); return regexes[i][1]; })); inputText = $output.val(); } } function checkReplace(match, $1, $2, $3, $4) { console.log(match + ':::' + $1 + ':::' + $2 + ':::' + $3 + ':::' + $4); if ($1 > 200) $1 = parseInt($1 / 2); if ($2 > 200) $2 = parseInt($2 / 2); return [$1,$2]; }

    Read the article

  • Problems with this code?

    - by J4C3N-14
    I'm trying to use this code which is an example taken from here https://gist.github.com/2383248 , but it is coming up with a error on the public void onClick which is Multiple markers at this line - implements android.view.View.OnClickListener.onClick - Syntax error, insert "}" to complete MethodBody, but when I add the brace it just throws another error after many tries and fails of different suggestions and ideas. It may be a syntax error and bad coding from me (just started learning to program) but does anyone have any ideas how to resolve this or point me in the right direction I would be very grateful. public class ICSCalendarActivity extends Activity implements View.OnClickListener{ Button button1; int year1; int month1; int day1; int ShiftPattern; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button1 = (Button)findViewById(R.id.openButton); button1.setText("open"); button1.setOnClickListener(this); Bundle extras = getIntent().getExtras(); year1 = extras.getInt("year1"); day1 = extras.getInt("day1"); month1 = extras.getInt("month1"); ShiftPattern = extras.getInt("ShiftPattern"); } public void onClick(View v){ private static void addToCalendar(Context ICSCalendarActivity, final String title, final long dtstart, final long dtend) { final ContentResolver cr = ICSCalendarActivity.getContentResolver(); Cursor cursor ; if (Integer.parseInt(Build.VERSION.SDK) >= 8 ) cursor = cr.query(Uri.parse("content://com.android.calendar/calendars"), new String[]{ "_id", "displayname" }, null, null, null); else cursor = cr.query(Uri.parse("content://calendar/calendars"), new String[]{ "_id", "displayname" }, null, null, null); if ( cursor.moveToFirst() ) { final String[] calNames = new String[cursor.getCount()]; final int[] calIds = new int[cursor.getCount()]; for (int i = 0; i < calNames.length; i++) { calIds[i] = cursor.getInt(0); calNames[i] = cursor.getString(1); cursor.moveToNext(); } AlertDialog.Builder builder = new AlertDialog.Builder(ICSCalendarActivity); builder.setSingleChoiceItems(calNames, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ContentValues cv = new ContentValues(); cv.put("calendar_id", calIds[which]); cv.put("title", title); cv.put("dtstart", dtstart ); cv.put("hasAlarm", 1); cv.put("dtend", dtend); Uri newEvent ; if (Integer.parseInt(Build.VERSION.SDK) >= 8 ) newEvent = cr.insert(Uri.parse("content://com.android.calendar/events"), cv); else newEvent = cr.insert(Uri.parse("content://calendar/events"), cv); if (newEvent != null) { long id = Long.parseLong( newEvent.getLastPathSegment() ); ContentValues values = new ContentValues(); values.put( "event_id", id ); values.put( "method", 1 ); values.put( "minutes", 15 ); // 15 minutes if (Integer.parseInt(Build.VERSION.SDK) >= 8 ) cr.insert( Uri.parse( "content://com.android.calendar/reminders" ), values ); else cr.insert( Uri.parse( "content://calendar/reminders" ), values ); } dialog.cancel(); } }); builder.create().show(); } cursor.close(); } } Thank you.

    Read the article

  • jQuery urlencode/decode patch help

    - by jeerose
    Hi Gang, I'm using this jQuery urlencode and urldecode plugin - very simple and easy to use but it doesn't, in its original form, remove + from the string. The one comment on the home page suggests a patch but I don't know how to implement it. Can anyone help me out? The Page: http://www.digitalbart.com/jquery-and-urlencode/ //URL Encode/Decode $.extend({URLEncode:function(c){var o='';var x=0;c=c.toString(); var r=/(^[a-zA-Z0-9_.]*)/; while(x<c.length){var m=r.exec(c.substr(x)); if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length; }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16); o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}, URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/; while((m=r.exec(o))!=null && m.length>1 && m[1]!=''){ b=parseInt(m[1].substr(1),16); t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;} }); The proposed Patch: function dummy_url_decode(url) { // fixed -- + char decodes to space char var o = url; var binVal, t, b; var r = /(%[^%]{2}|\+)/; while ((m = r.exec(o)) != null && m.length > 1 && m[1] != '') { if (m[1] == '+') { t = ' '; } else { b = parseInt(m[1].substr(1), 16); t = String.fromCharCode(b); } o = o.replace(m[1], t); } return o; } Thanks!

    Read the article

  • Is there a problem with scrollTop in Chrome?

    - by Shaun
    I am setting scrollTop and scrollLeft for a div that I am working with. The code looks like this: div.scrollLeft = content.cx*scalar - parseInt(div.style.width)/2; div.scrollTop = content.cy*scalar - parseInt(div.style.height)/2; This works just fine in FF, but only scrollLeft works in chrome. As you can see, the two use almost identical equations and as it works in FF I am just wondering if this is a problem with Chrome? Update: If I switch the order of the assignments then scrollTop will work and scrollLeft won't. <div id="container" style = "height:600px; width:600px; overflow:auto;" onscroll = "updateCenter()"> <script> var div = document.getElementById('container'); function updateCenter() { svfdim.cx = (div.scrollLeft + parseFloat(div.style.width)/2)/scalar; svfdim.cy = (div.scrollTop + parseFloat(div.style.height)/2)/scalar; } function updateScroll(svfdim, scalar, div) { div.scrollTop = svgdim.cy*scalar - parseFloat(div.style.height)/2; div.scrollLeft = svgdim.cx*scalar - parseFloat(div.style.width)/2; } function resizeSVG(Root) { Root.setAttribute("height", svfdim.height*scalar); Root.setAttribute("width", svfdim.width*scalar); updateScroll(svgdim, scalar, div); } </script>

    Read the article

  • Eclipse Error On Startup

    - by GuyNoir
    Eclipse was running fine last night, but this morning I tried starting it up and I came upon this error: Here's the log !SESSION 2010-04-07 17:58:37.208 ----------------------------------------------- eclipse.buildId=I20080617-2000 java.version=1.6.0_13 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86 !ENTRY org.eclipse.osgi 4 0 2010-04-07 17:58:37.457 !MESSAGE Startup error !STACK 1 java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at org.eclipse.osgi.storagemanager.StorageManager.updateTable(StorageManager.java:512) at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:694) at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initFileManager(BaseStorage.java:208) at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initialize(BaseStorage.java:142) at org.eclipse.osgi.baseadaptor.BaseAdaptor.initializeStorage(BaseAdaptor.java:124) at org.eclipse.osgi.framework.internal.core.Framework.initialize(Framework.java:180) at org.eclipse.osgi.framework.internal.core.Framework.<init>(Framework.java:152) at org.eclipse.osgi.framework.internal.core.OSGi.createFramework(OSGi.java:90) at org.eclipse.osgi.framework.internal.core.OSGi.<init>(OSGi.java:31) at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:286) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) Any help? I really need this up and running, and reinstalling and resetting all of my plugins and settings just isn't an option at the moment.

    Read the article

  • Iterating throgh mvc model lists using javascript

    - by kapil
    I want to iterate through my model values. Following is what I did to achieve this. But the varible count never increments. How can I increment it to iterate throgh my model values? <script language="javascript" type="text/javascript"> function AddStudentName() { var StudentName = document.getElementById('txtStudentName').value; StudentName= StudentName.replace(/^\s+|\s+$/g, ''); if(StudentName!= null) { <%int count = 0; %> for(var counter = 0; parseInt(counter)< parseInt('<%=Model.StudentInfo.Count%>',10); counter++) { alert('<%=count%>'); if('<%=Model.StudentInfo[count].StudentName%>' == StudentName) { alert("A student with new student name already exists."); return false; } <%count = count +1;%> } } } </script> thanks, Kapil

    Read the article

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