JavaScript - How Does This Button Without Onclick, Post Etc Call Javascript?
I am trying to understand a button that calls a script without any onclick event, post or similar. I do not have a clue ...
This is the code of the button Code: <div class="sNR"> <button type="button" class="sLR" id="gwt-debug-searchPanel-searchButton">Suchen</button> </div> From: Code: https://adwords.google.com/o/Targeting/Explorer?__u=1000000000&__c=1000000000&ideaRequestType=KEYWORD_IDEAS#search.none Is there any software that help would help me? PS: You need firebug or an equivalent to view the code. Similar TutorialsHi, This button changes the button text when clicked, but it is always calling the same function. How to make the button depending on the button text to call different functions on onclick? [CODE] <script type = "text/javascript"> function button_switch(){ if (document.switch_form.switch_b.value == "Adam"){ document.switch_form.switch_b.value="Eva"; } else{ document.switch_form.switch_b.value = "Adam"; } } </script> <form name = "switch_form"> <input type = "button" name = "switch_b" id = "switch_b" value = "Adam" onclick = "button_switch()" /> </form> [CODE] Hi Guys, I am trying to make a change to my website so when someone clicks on the chinese flag image, for example, a function which put the clock forward a few hours. This is what the code I have got at the moment: <td><a href="<? echo $_SERVER[PHP_SELF].'?page='.$page.'&lang=en'; ?>"><img src="images/uk.gif" title="english" border=0></a></td> <td><a href="<? echo $_SERVER[PHP_SELF].'?page='.$page.'&lang=zh'; ?>"><img src="images/ch.gif" title="chinese" onclick="chinatime()" border=0></a></td> <td><a href="<? echo $_SERVER[PHP_SELF].'?page='.$page.'&lang=ja'; ?>"><img src="images/jap.gif" title="japanese" border=0></a></td> <td><a href="<? echo $_SERVER[PHP_SELF].'?page='.$page.'&lang=kk'; ?>"><img src="images/kaz.gif" title="kazakh" border=0></a></td> <td><a href="<? echo $_SERVER[PHP_SELF].'?page='.$page.'&lang='.$most_preferred; ?>">Browser Set</a></td> </tr> <tr> <td colspan="5"> <p class="meta"><span class="date"><script type="text/javascript"> var currentTime = new Date() var minutes = currentTime.getMinutes() var hours = currentTime.getHours() var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear() function chinatime() { hours = hours + 5 } if (minutes < 10) minutes = "0" + minutes document.write(day + "/" + month + "/" + year + " " + hours +":"+minutes) </script> Many Thanks I am very new Beginner of Javascript.. My query is that 1)I have 2 radio buttons A and B 2)When I click A I want 2 dropdownbox and a button to be displayed 3)When I click B I want 2 dropdownbox to be displayed. 4)Both should be independent Plz tell me the code..for this I need to make a table fadeout with JavaScript when I click a button. The table is simple. Code: <table id="users_table" style="border:1px solid #000;border-collapse: collapse;" border='1'> <tr class="dataRow"> <td>11</td> <td>12</td> <td>13</td> </tr> <tr class="dataRow"> <td>21</td> <td>22</td> <td>23</td> </tr> <tr id="row3" class="dataRow"> <td>31</td> <td>32</td> <td>33</td> </tr> <tr class="dataRow"> <td>41</td> <td>42</td> <td>43</td> </tr> </table> There is a button that calls a function called fadeout(). I cannot find a way to make the table fade out with just that one function. Is that even possible? If not, what other functions are necessary to make this happen? Hey, In the quiz function the form that is generated all compiles correctly, but the submit button only causes the page to refresh. What am I doing wrong? Thank you var c = "1"; //counter var n = [68]; //array that stores unique random numbers var t = "better clear"; var lc = [3]; var uc = [3]; ////////////////////////////////////////////// //The generate() function generates 68 random //unique numbers. ////////////////////////////////////////////// function generate() { var gen = 0; //variable that stores random integer. var j = 1, i = 1; //integers used for loops while (j <= 68) { gen = Math.floor(Math.random()*68+1); for (i = 1; i <= j; i++) { if (n[i] == gen) { break; } else { if (i == j) { n [j] = gen; j++; break; } } } } } ////////////////////////////////////////////// //The rinfo() function reads information that //is pertinent to current question (quality //of triad (t), upper case, and //lower case answers to the question). ////////////////////////////////////////////// function rinfo() { if (n[c] == 1) { t = "a C Major"; lc[3] = "c"; //root uc[3] = "C"; //root lc[2] = "e"; //third uc[2] = "E"; //third lc[1] = "g"; //fifth uc[1] = "G"; //fifth } if (n[c] == 2) { t = "a C Minor"; lc[3] = "c"; //root uc[3] = "C"; //root lc[2] = "eb"; //third uc[2] = "Eb"; //third lc[1] = "g"; //fifth uc[1] = "G"; //fifth } if (n[c] == 3) { t = "a C Augmented"; lc[3] = "c"; //root uc[3] = "C"; //root lc[2] = "e"; //third uc[2] = "E"; //third lc[1] = "g#"; //fifth uc[1] = "G#"; //fifth } if (n[c] == 4) { t = "a C Diminished"; lc[3] = "c"; //root uc[3] = "C"; //root lc[2] = "eb"; //third uc[2] = "Eb"; //third lc[1] = "gb"; //fifth uc[1] = "Gb"; //fifth } if (n[c] == 5) { t = "a F Major"; lc[3] = "f"; //root uc[3] = "F"; //root lc[2] = "a"; //third uc[2] = "A"; //third lc[1] = "c"; //fifth uc[1] = "C"; //fifth } if (n[c] == 6) { t = "a F Minor"; lc[3] = "f"; //root uc[3] = "F"; //root lc[2] = "ab"; //third uc[2] = "Ab"; //third lc[1] = "c"; //fifth uc[1] = "C"; //fifth } if (n[c] == 7) { t = "a F Augmented"; lc[3] = "f"; //root uc[3] = "F"; //root lc[2] = "a"; //third uc[2] = "A"; //third lc[1] = "c#"; //fifth uc[1] = "C#"; //fifth } if (n[c] == 8) { t = "a F Diminished"; lc[3] = "f"; //root uc[3] = "F"; //root lc[2] = "ab"; //third uc[2] = "Ab"; //third lc[1] = "cb"; //fifth uc[1] = "Cb"; //fifth } if (n[c] == 9) { t = "a Bb Major"; lc[3] = "bb"; //root uc[3] = "Bb"; //root lc[2] = "d"; //third uc[2] = "D"; //third lc[1] = "f"; //fifth uc[1] = "F"; //fifth } if (n[c] == 10) { t = "a Bb Minor"; lc[3] = "bb"; //root uc[3] = "Bb"; //root lc[2] = "db"; //third uc[2] = "Db"; //third lc[1] = "f"; //fifth uc[1] = "F"; //fifth } if (n[c] == 11) { t = "a Bb Augmented"; lc[3] = "bb"; //root uc[3] = "Bb"; //root lc[2] = "d"; //third uc[2] = "D"; //third lc[1] = "f#"; //fifth uc[1] = "F#"; //fifth } if (n[c] == 12) { t = "a Bb Diminished"; lc[3] = "bb"; //root uc[3] = "Bb"; //root lc[2] = "db"; //third uc[2] = "Db"; //third lc[1] = "fb"; //fifth uc[1] = "Fb"; //fifth } if (n[c] == 13) { t = "an Eb Major"; lc[3] = "eb"; //root uc[3] = "Eb"; //root lc[2] = "g"; //third uc[2] = "G"; //third lc[1] = "bb"; //fifth uc[1] = "Bb"; //fifth } if (n[c] == 14) { t = "an Eb Minor"; lc[3] = "eb"; //root uc[3] = "Eb"; //root lc[2] = "gb"; //third uc[2] = "Gb"; //third lc[1] = "bb"; //fifth uc[1] = "Bb"; //fifth } if (n[c] == 15) { t = "an Eb Augmented"; lc[3] = "eb"; //root uc[3] = "Eb"; //root lc[2] = "g"; //third uc[2] = "G"; //third lc[1] = "b#"; //fifth uc[1] = "B#"; //fifth } if (n[c] == 16) { t = "an Eb Diminished"; lc[3] = "eb"; //root uc[3] = "Eb"; //root lc[2] = "gb"; //third uc[2] = "Gb"; //third lc[1] = "bbb"; //fifth uc[1] = "Bbb"; //fifth } if (n[c] == 17) { t = "an Ab Major"; lc[3] = "ab"; //root uc[3] = "Ab"; //root lc[2] = "c"; //third uc[2] = "C"; //third lc[1] = "e"; //fifth uc[1] = "E"; //fifth } if (n[c] == 18) { t = "an Ab Minor"; lc[3] = "ab"; //root uc[3] = "Ab"; //root lc[2] = "cb"; //third uc[2] = "Cb"; //third lc[1] = "eb"; //fifth uc[1] = "Eb"; //fifth } if (n[c] == 19) { t = "an Ab Augmented"; lc[3] = "ab"; //root uc[3] = "Ab"; //root lc[2] = "c"; //third uc[2] = "C"; //third lc[1] = "e"; //fifth uc[1] = "E"; //fifth } if (n[c] == 20) { t = "an Ab Diminished"; lc[3] = "ab"; //root uc[3] = "Ab"; //root lc[2] = "cb"; //third uc[2] = "Cb"; //third lc[1] = "eb"; //fifth uc[1] = "Eb"; //fifth } if (n[c] == 21) { t = "a Db Major"; lc[3] = "db"; //root uc[3] = "Db"; //root lc[2] = "f"; //third uc[2] = "F"; //third lc[1] = "a"; //fifth uc[1] = "A"; //fifth } if (n[c] == 22) { t = "a Db Minor"; lc[3] = "db"; //root uc[3] = "Db"; //root lc[2] = "fb"; //third uc[2] = "Fb"; //third lc[1] = "ab"; //fifth uc[1] = "Ab"; //fifth } if (n[c] == 23) { t = "a Db Augmented"; lc[3] = "db"; //root uc[3] = "Db"; //root lc[2] = "f"; //third uc[2] = "F"; //third lc[1] = "a#"; //fifth uc[1] = "A#"; //fifth } if (n[c] == 24) { t = "a Db Diminished"; lc[3] = "db"; //root uc[3] = "Db"; //root lc[2] = "fb"; //third uc[2] = "Fb"; //third lc[1] = "abb"; //fifth uc[1] = "Abb"; //fifth } if (n[c] == 25) { t = "a Gb Major"; lc[3] = "gb"; //root uc[3] = "Gb"; //root lc[2] = "bb"; //third uc[2] = "Bb"; //third lc[1] = "db"; //fifth uc[1] = "Db"; //fifth } if (n[c] == 26) { t = "a Gb Minor"; lc[3] = "gb"; //root uc[3] = "Gb"; //root lc[2] = "bbb"; //third uc[2] = "Bbb"; //third lc[1] = "db"; //fifth uc[1] = "Db"; //fifth } if (n[c] == 27) { t = "a Gb Augmented"; lc[3] = "gb"; //root uc[3] = "Gb"; //root lc[2] = "bb"; //third uc[2] = "Bb"; //third lc[1] = "d"; //fifth uc[1] = "D"; //fifth } if (n[c] == 28) { t = "a Gb Diminished"; lc[3] = "gb"; //root uc[3] = "Gb"; //root lc[2] = "bbb"; //third uc[2] = "Bbb"; //third lc[1] = "dbb"; //fifth uc[1] = "Dbb"; //fifth } if (n[c] == 29) { t = "a B Major"; lc[3] = "b"; //root uc[3] = "B"; //root lc[2] = "d#"; //third uc[2] = "D#"; //third lc[1] = "f#"; //fifth uc[1] = "F#"; //fifth } if (n[c] == 30) { t = "a B Minor"; lc[3] = "b"; //root uc[3] = "B"; //root lc[2] = "d"; //third uc[2] = "D"; //third lc[1] = "f#"; //fifth uc[1] = "F#"; //fifth } if (n[c] == 31) { t = "a B Augmented"; lc[3] = "b"; //root uc[3] = "B"; //root lc[2] = "d#"; //third uc[2] = "D#"; //third lc[1] = "fx"; //fifth uc[1] = "Fx"; //fifth } if (n[c] == 32) { t = "a B Diminished"; lc[3] = "b"; //root uc[3] = "B"; //root lc[2] = "d"; //third uc[2] = "D"; //third lc[1] = "f"; //fifth uc[1] = "F"; //fifth } if (n[c] == 33) { t = "an E Major"; lc[3] = "e"; //root uc[3] = "E"; //root lc[2] = "g#"; //third uc[2] = "G#"; //third lc[1] = "b"; //fifth uc[1] = "B"; //fifth } if (n[c] == 34) { t = "an E Minor"; lc[3] = "e"; //root uc[3] = "E"; //root lc[2] = "g"; //third uc[2] = "G"; //third lc[1] = "b"; //fifth uc[1] = "B"; //fifth } if (n[c] == 35) { t = "an E Augmented"; lc[3] = "e"; //root uc[3] = "E"; //root lc[2] = "g#"; //third uc[2] = "G#"; //third lc[1] = "b#"; //fifth uc[1] = "B#"; //fifth } if (n[c] == 36) { t = "an E Diminished"; lc[3] = "e"; //root uc[3] = "E"; //root lc[2] = "g"; //third uc[2] = "G"; //third lc[1] = "bb"; //fifth uc[1] = "Bb"; //fifth } if (n[c] == 37) { t = "an A Major"; lc[3] = "a"; //root uc[3] = "A"; //root lc[2] = "c#"; //third uc[2] = "C#"; //third lc[1] = "e"; //fifth uc[1] = "E"; //fifth } if (n[c] == 38) { t = "an A Minor"; lc[3] = "a"; //root uc[3] = "A"; //root lc[2] = "c"; //third uc[2] = "C"; //third lc[1] = "e"; //fifth uc[1] = "E"; //fifth } if (n[c] == 39) { t = "an A Augmented"; lc[3] = "a"; //root uc[3] = "A"; //root lc[2] = "c#"; //third uc[2] = "C#"; //third lc[1] = "e#"; //fifth uc[1] = "E#"; //fifth } if (n[c] == 40) { t = "an A Diminished"; lc[3] = "a"; //root uc[3] = "A"; //root lc[2] = "c"; //third uc[2] = "C"; //third lc[1] = "eb"; //fifth uc[1] = "Eb"; //fifth } if (n[c] == 41) { t = "a D Major"; lc[3] = "d"; //root uc[3] = "D"; //root lc[2] = "f#"; //third uc[2] = "F#"; //third lc[1] = "a"; //fifth uc[1] = "A"; //fifth } if (n[c] == 42) { t = "a D Minor"; lc[3] = "d"; //root uc[3] = "D"; //root lc[2] = "f"; //third uc[2] = "F"; //third lc[1] = "a"; //fifth uc[1] = "A"; //fifth } if (n[c] == 43) { t = "a D Augmented"; lc[3] = "d"; //root uc[3] = "D"; //root lc[2] = "f#"; //third uc[2] = "F#"; //third lc[1] = "a#"; //fifth uc[1] = "A#"; //fifth } if (n[c] == 44) { t = "a D Diminished"; lc[3] = "d"; //root uc[3] = "D"; //root lc[2] = "f"; //third uc[2] = "F"; //third lc[1] = "ab"; //fifth uc[1] = "Ab"; //fifth } if (n[c] == 45) { t = "a G Major"; lc[3] = "g"; //root uc[3] = "G"; //root lc[2] = "b"; //third uc[2] = "B"; //third lc[1] = "d"; //fifth uc[1] = "D"; //fifth } if (n[c] == 46) { t = "a G Minor"; lc[3] = "g"; //root uc[3] = "G"; //root lc[2] = "bb"; //third uc[2] = "Bb"; //third lc[1] = "d"; //fifth uc[1] = "D"; //fifth } if (n[c] == 47) { t = "a G Augmented"; lc[3] = "g"; //root uc[3] = "G"; //root lc[2] = "b"; //third uc[2] = "B"; //third lc[1] = "d#"; //fifth uc[1] = "D#"; //fifth } if (n[c] == 48) { t = "a G Diminished"; lc[3] = "g"; //root uc[3] = "G"; //root lc[2] = "bb"; //third uc[2] = "Bb"; //third lc[1] = "db"; //fifth uc[1] = "Db"; //fifth } if (n[c] == 49) { t = "an A# Major"; lc[3] = "a#"; //root uc[3] = "A#"; //root lc[2] = "cx"; //third uc[2] = "Cx"; //third lc[1] = "e#"; //fifth uc[1] = "E#"; //fifth } if (n[c] == 50) { t = "an A# Minor"; lc[3] = "a#"; //root uc[3] = "A#"; //root lc[2] = "c#"; //third uc[2] = "C#"; //third lc[1] = "e#"; //fifth uc[1] = "E#"; //fifth } if (n[c] == 51) { t = "an A# Augmented"; lc[3] = "a#"; //root uc[3] = "A#"; //root lc[2] = "cx"; //third uc[2] = "Cx"; //third lc[1] = "ex"; //fifth uc[1] = "Ex"; //fifth } if (n[c] == 52) { t = "an A# Diminished"; lc[3] = "a#"; //root uc[3] = "A#"; //root lc[2] = "c#"; //third uc[2] = "C#"; //third lc[1] = "e"; //fifth uc[1] = "E"; //fifth } if (n[c] == 53) { t = "a D# Major"; lc[3] = "d#"; //root uc[3] = "D#"; //root lc[2] = "fx"; //third uc[2] = "Fx"; //third lc[1] = "a#"; //fifth uc[1] = "A#"; //fifth } if (n[c] == 54) { t = "a D# Minor"; lc[3] = "d#"; //root uc[3] = "D#"; //root lc[2] = "f#"; //third uc[2] = "F#"; //third lc[1] = "a#"; //fifth uc[1] = "A#"; //fifth } if (n[c] == 55) { t = "a D# Augmented"; lc[3] = "d#"; //root uc[3] = "D#"; //root lc[2] = "fx"; //third uc[2] = "Fx"; //third lc[1] = "ax"; //fifth uc[1] = "Ax"; //fifth } } function first() { alert("W"); } function quiz() { generate(); while (c <= 1) { rinfo(); var output_text = c + ". " + "Enter " + t + " triad."; document.write("<h3>"); document.writeln(output_text); document.write("</h3>"); document.write(" <form align = \"center\">"); document.write(" <input type = \"text\" size = \"2\" name = \"root\" value = \"\" maxlength = \"2\">"); document.write(" <input type = \"text\" size = \"2\" name = \"third\" value = \"\" maxlength = \"2\">"); document.write(" <input type = \"text\" size = \"2\" name = \"fifth\" value = \"\" maxlength = \"2\">"); document.write(" <input type = \"hidden\" name = \"question\" value = 1>"); document.write(" <input type = \"submit\" value=\"Check your answer\" onclick=\"first();\">"); document.write(" <\/form>"); c++; } } Code: Quote: Code: Quote: Code: Quote: can somebody please tell me what need done. Everything is working fine except for the button created in javascript that is in the second window which is to open the third window. Thanks. Hello, Is it possible to set an html element's (created through HTML DOM's createElement() method) 'onclick' attribute's value to a Javascript function which requires a parameter, passing a variable to it at the same time? I have the following Javascript code: Code: var parentDiv = document.getElementById("subscribers"); var stubSpan = document.createElement("span"); stubSpan.id = "opentok_subscriber_" + stream.streamId; stubSpan.onclick = showStreamInFullScreenMode(stream); parentDiv.appendChild(stubSpan); 'stream' in the bolded line is a parameter variable of the function that the above code is in, and I'm trying to pass it to another function using an onclick event. Can this be done, or am I crazy to be even trying to do this? Thanks in advance. All, I have the following code: Code: $(function() { $("#check_login").click(function() { event.preventDefault(); var $email = $("#login_email").val(); var $password = $("#login_password").val(); $.post("check.php", {email: $email, password: $password}, function(result) { if(result=="Success"){ parent.$.fancybox.close(); window.location.replace("index.php"); }else{ $("#login_check").html(result); $("#login_email").val(''); $("#login_password").val(''); } }); }); }); I'm basically checking a user login. If the login is successful I'd like to close the Fancybox. This part works fine. I'm using an iFrame from Fancybox. If I don't have this part: Code: parent.$.fancybox.close(); It will reload the index page in my iFrame. How can I refresh my other page from the iFrame? Thanks in advance. I'm trying to get a submit button to open a thank you page I created (i.e. thankyou.html) only after the user has filled out a series of questions for a form. If they don't fill out the required information, a pop up box informs them to fill out the section (this I have accomplished). I cannot get the submit button to not work if the fields are left un-answered. Can you guys help? Thanks for you help. -------------------------------------------------------------------------- This is what I have so far: <title>Customer Demographic Data Form</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" ></meta> <style type="text/css"> body { font-family: Times New Roman; color: navy; background-color: #CCC } h1, h2, h5 { font-family: Times New Roman; color: black } body,td,th { color: #000; font-family: Times New Roman, Times, serif; } h1 { color: #000; } h2 { color: #000; } h5 { color: #000; } a { font-family: Times New Roman, Times, serif; } h1,h2,h3,h4,h5,h6 { font-family: Times New Roman, Times, serif; } </style> <script type="text/javascript"> function checkForNumber(fieldValue) { var numberCheck = isNaN(fieldValue); if (numberCheck == true) { window.alert("Please enter a numeric value!"); return false; } } function confirmSubmit() { var email = document.forms[0].email.value; if (document.forms[0].fname.value == "" || document.forms[0].lname.value == "") { window.alert("Please enter your first and last name."); document.forms[0].lname.focus(); return false; } else if (document.forms[0].address1.value == "" && document.forms[0].email.value == "") { window.alert("Please enter your Mailing Address or Email Address!"); document.forms[0].address1.focus(); return false; } else if (email.indexOf("@") == -1 && document.forms[0].email.value != "") { window.alert("Please enter a valid e-mail address."); document.forms[0].email.focus(); return false; } else if (email.indexOf(".") == -1 && document.forms[0].email.value != "") { window.alert("Please enter a valid e-mail address."); document.forms[0].email.focus(); return false; } else if(document.forms[0].city.value == '') { window.alert("Please enter your City"); document.forms[0].city.focus(); return false; } else if(document.forms[0].state.value == '') { window.alert("Please enter your State"); document.forms[0].state.focus(); return false; } else if(document.forms[0].zip.value == '') { window.alert("Please enter your Zip Code"); document.forms[0].zip.focus(); return false; } checkCookie() } function checkCookie() { var formInfo = decodeURI(document.cookie); var userInfo = formInfo.split("; "); var lname = userInfo[0].split("="); var fname = userInfo[1].split("="); if (lname[1] == document.forms[0].lname.value && fname[1] == document.forms[0].fname.value) { this.close(true); window.open("FormDenied.html"); return false; } else { setCookie(); return true; } } function setCookie() { var expiresDate = new Date(); expiresDate.setFullYear(expiresDate.getFullYear() + 1); document.cookie = encodeURI("lname=" + document.forms[0].lname.value) + "; expires=" + expiresDate.toUTCString(); document.cookie = encodeURI("fname=" + document.forms[0].fname.value) + "; expires=" + expiresDate.toUTCString(); window.alert("Your information has been saved."); } </script> </head> <body> <p> </p> <h1 align="left" style="text-align: left">Kudler Fine Foods contact form</h1> <form action="" method="get" enctype="application/x-www-form-urlencoded" onsubmit="return confirmSubmit();" onreset="return confirmReset();" > <blockquote> <h2><u>Name</u></h2> <p> <input type="text" name="fname" id="fname" size="25" /> <label for="fname"><strong>First Name</strong><br> <br> </label> <input type="text" name="lname" id="lname" size="15" /> <strong>Last Name</strong></p> <h2>---------------------------------------<br> <u>Address</u> </h2> <p> <input type="text" name="address1" id="address1" size="30" /> <label for="address1"><strong>Address Line 1</strong></label> </p> <p> <input type="text" name="address2" id="address2" size="20" /> <strong>Address Line 2<br> <br> </strong> <input type="text" name="city" id="city" size="20" /> <strong>City</strong> </p> <p> <input type="text" name="state" id="state" size="2" /> <label for="state2"><strong>State</strong></label> </p> <p> <input type="text" name="zip" id="zip" size="10" maxlength="10" onChange="return checkForNumber(this.value);" /> <label for="zip2"><strong>Zip Code</strong></label> </p> <h2>--------------------------------------- </h2> <h2> <u>Other Information</u></h2> <table> <tr> <td width=300><strong>Telephone</strong></td> <td width=300><p><strong>Email address:</strong></p></td> </tr> <tr> <td> <input type="text" name="area" id="area" size="3" maxlength="3" onChange="return checkForNumber(this.value);" /> <input type="text" name="exchange" id="exchange" size="3" maxlength="3" onChange="return checkForNumber(this.value);" /> <input type="text" name="phone" id="phone" size="4" maxlength="4" onChange="return checkForNumber(this.value);" /></td> <td> <input type="text" name="email" id="email" size="30" /></td> </tr> </table> </blockquote> <h5> </h5> <blockquote><blockquote> <h3 align="center"> <input name="Submit" type="button" </h3> </blockquote> </blockquote> </form> </body> </html> How do I change the Button's value onClick? I want it to initially be "Read More" and then change to "Show Less" Code: <script type="text/javascript"> function toggleMe(a){ var e=document.getElementById(a); if(!e)return true; if(e.style.display=="none"){ e.style.display="block" } else{ e.style.display="none" } return true; } </script> <div>Why are we going to stop making investments in companies like this?</div> <span id="obamaenergyapril212011" style="display:none;"> END 12:50 P.M. PDT</span> <input type="button" name="obama" onclick="return toggleMe('obamaenergyapril212011')" value="Read/Hide More" > I'm a newbie Javascript coder and I've run into a little problem. I hope someone can help me with it. The idea is that I've got a bunch of images, and I want one thing to fire when left-clicking them and a different thing when right-clicking. For the purpose of this thread I've replaced the 'things' with alerts. this is the part that gets added to the images (called 'plaatje'): Code: plaatje.onclick = klik; this is the function that gets executed when clicked. Code: function klik(event) { var fotoID = event.target.id; if (event.button == 0) { alert("Left click on " + fotoID + "!"); } else if (event.button == 2) { event.preventDefault(); alert("Right click on " + fotoID + "!"); } } I've added the "event.preventDefault();" part because I was told that would prevent the right-click menu from popping up. The problem is that the left-click part of the code works perfectly, but the right-click part does nothing. The right-click menu comes up as normal and the alert never shows. Can anyone tell me what I'm doing wrong? What have I done wrong here? <INPUT id="purchase" onclick="document.getElementById("purchase").disabled = true;" type="submit" value="PURCHASE"> As the code example below shows, I have three radio buttons that perform an javascript action when selected. Code: <script language="javascript"> function OnProductClick(product) { if (product.value == "Car") { // do something } else if (product.value == "Boat") { // do something else.. } else if (product.value == "Train") { // do else } } </script> <p>Select option <input type="radio" name="product" onclick="OnProductClick(this)" value="Car">Car</input> <input type="radio" name="product" onclick="OnProductClick(this)" value="Boat"> Boat</input> <input type="radio" name="product" onclick="OnProductClick(this)" value="Train">Train</input> </p> This setup is triggerred by a click, clicking multiple times on the same radio button will yield multiple calls to the OnProductClick function. This last part is what I would like to prevent. Say a user selects the option 'car' and then for some reason clicks on the same option again, this will lead to the OnProductClick function being executed twice. How can I prevent the second execution? hi guys im trying to check whether a radio button is checked when i click it, but the javascript onlick event is not acting cool! when i click an unselected radio button i am informed that the unselected radio button i just clicked is in fact checked, when i should be getting the information the no, the radio button was not checked when i clicked it. any idea how to get the previous state of a radio button onclick? All, I have the following code: Code: <input type="button" name="button" value="Submit" onclick="javascript:get(this.myform);"> How can I change this to make this button disabled after the onclick? Thanks in advance. I have identical code in my index that works, so I'm just guessing the error is somewhere else, I know IE is not the best target to aim for - but I really want this to work in the windows default browser.... Here is the php page... PHP Code: <HTML> <HEAD> <TITLE> Family Home Page </TITLE> <SCRIPT TYPE="text/javascript" SRC="AddFamilyMemeber.js"> </SCRIPT> </HEAD> <BODY> <TABLE> <TR> <TD>Father:</TD> <TD> <SELECT ID="Father"> <?PHP $con=mysql_connect("localhost","XXXX","XXXX"); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("XXXX",$con); $result=mysql_query("SELECT * FROM FamilyMembers"); while ($row=mysql_fetch_array($result)) { echo "<OPTION VALUE=\"".$row['ID']."\">".$row['FirstName']." ".$row['MiddleName']." ".$row['LastName']."</OPTION>"; echo "<BR/>\n"; } mysql_close($con); ?> </SELECT> </TD> </TR> <TR> <TD>Mother:</TD> <TD> <SELECT ID="Mother"> <?PHP $con=mysql_connect("localhost","XXXX","XXXX"); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("XXXX",$con); $result=mysql_query("SELECT * FROM FamilyMembers"); while ($row=mysql_fetch_array($result)) { echo "<OPTION VALUE=\"".$row['ID']."\">".$row['FirstName']." ".$row['MiddleName']." ".$row['LastName']."</OPTION>"; echo "<BR/>\n"; } mysql_close($con); ?> </SELECT> <TD> </TR> <TR> <TD>FirstName:</TD> <TD><INPUT TYPE="text" ID="FirstName"/></TD> </TR> <TR> <TD>MiddleName:</TD> <TD><INPUT TYPE="text" ID="MiddleName"/></TD> </TR> <TR> <TD>LastName:</TD> <TD><INPUT TYPE="text" ID="LastName"/></TD> </TR> </TABLE> <BUTTON TYPE="button" ONCLICK="Submit()">Submit</BUTTON> <BUTTON TYPE="button" ONCLICK="Abort()">Abort</BUTTON> </BODY> </HTML> and here is the javascript that works in the index but not here... Code: function Abort() { document.location="AddFamilyMember.php"; }; When I load the page everything looks ok, but click on the abort button, and all that happens is that the little error symbol pops in the lower left of IE. The names of the two files are "AddFamilyMember.php" and "AddFamilyMember.js". Sorry, but I honestly can't see where the problem is.... Hi there, I'm soo stuck on particular piece of code.. You see i have 2 radio buttons with values 12hr and 24hr; on clicking any of the above the time format should change automatically. by default the time format comes in 12hr format against onload event of <body>. I've tried using javascript but this problem is persisting... Can anyone help me pleassssse.. I am using 2 ajax functions in the program. One for login and one for logout. The login one is showUser which is working correctly by using the form onsubmit method, however the logout button (IN BOLD) onclick method is not working. Pls help. Code: <form onsubmit="showUser(document.getElementById('uid').value,document.getElementById('pass').value);return false;" > <div id="txt"><b>Enter your username </b> <input type="text" name= "username" id="uid"> <br> <b>Enter your password</b> <input type="password" name="pass" id="pass"> <br></div> <div id="txt1" style="display : none">help</div> <input type="submit" value="Login" /> <input type="button" onclick="logout(document.getElementById('uid').value); return false; " name="logout" value="Logout" /> <input type="button" value="Register" class="register"/> </form> I just started my javascript class two weeks ago and am having troubles already and my book is no help. My first assignment is having a list of country names and when you click the radio button next to the name the country flag pops up in a designated area for the image. I have tried a few different things but nothing is working. I have the list of countrys and the radio buttons but when i click the radio button the image doesn't pop up. Also, when i click another radio button they all stay selected. Below is a script I found at http://bytes.com/topic/javascript/an...cookie-problem The idea is a like button, like on fb, in a form which updates a db field I can use to display the number of likes, and my goal is to disable the like button for the rest of the session, or a day, or whatever. This script disables it onclick, the problem is I can't figure out how to get it to submit the form as well. I have found it does submit if the input type is 'submit', but then it doesn't call the disable function. I tried writing another function to submit the form but no go. Code: <html> <head> <title>Vote Button</title> <script type="text/javascript"> function checkForVote() { // If there is a cookie... if(document.cookie != "") { if(getCookie("voted") == 1) { // Disable the button again if user already voted. disableButton(); } } } function disableButton() { var submitvote = document.getElementById("submitvote"); submitvote.disabled = true; submitvote.value = "You Already Voted."; } function setCookie(name, value, days) { if(days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires = " + date.toGMTString(); } else { var expires = ""; } document.cookie = name + "=" + value + expires + "; path=/"; // Disable the button as soon as the user clicks it. disableButton(); } function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') { c = c.substring(1,c.length); } if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length,c.length); } } return null; } </script> </head> <body> <form name="voteform" id="voteform" action="foo.php" method="post"> <input type="button" name="submitvote" id="submitvote" onclick="setCookie('voted', 1, -1);" value="Submit Vote"/> </form> </body> <script type="text/javascript"> // Run checkForVote() at end of document so that form and contents can be referenced window.onload = checkForVote(); </script> </html> |