JavaScript - Javascript Function Works On First Button, But Shows Same Output On Second Button
Hi,
I am not entirely sure what I am doing wrong here, and I have been looking at this for ages, so apologies in advance if I have become so bleary eyed I can't see something simple. I use php to create buttons based on values pulled for a table. The problem I have is when you click on the first button the javascript function works great, when you click on the next button you get the same output even though it should be different results. I am working in ff and I can see on my firebug console that the javascript function is being called, but it is not passing the new value of the second or third button, it just keeps repassing the value of the first button. So not entirely sure where I am going wrong here. My page is: Code: <script type="text/javascript"> function loadXMLDoc2(File,ID,Msg){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; } } var params=Msg; xmlhttp.open("POST",File,true); xmlhttp.setRequestHeader("Pragma", "Cache-Control:no-cache"); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(params); } </script> <head> <body> <?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); $result = mysql_query("SELECT DISTINCT theme FROM goods WHERE category='{$_POST['category']}' ORDER BY theme DESC"); while($row = mysql_fetch_array($result)){ echo '<input type="text" class="hidden" name="theme" id="theme" value="' . $row['theme'] . '" ><input type="button" class="button3" name="product" id="product" value="' . $row['product'] . '" onClick="loadXMLDoc2(\'getShow.php\',\'txtHint\',\'theme=\'+encodeURI(document.getElementById(\'rtheme\').value))" > '; } echo '<br /><br /> <div id="txtHint"><div> <br /> <br />'; mysql_close($con); ?> And getShow.php produces a table with a list of product images, names and prices, based on theme. So basically not sure where I am going wrong here? Similar TutorialsHi, I have 31 audio files and want to play one each day from a single html button. I have the audio files in the same directory as the html page. I have tried to adapt some code to do this, but have not had success. Any help would be much appreciated! Here is what I have so far: Code: <body> <button id="button" onclick=" " return false">Play</button> </body> <script type="text/javascript"> var currentDay = (new Date()).getDate(); document.getElementById('button').onclick = "proverbs" + currentDay + ".mp4" ; </script> i'm still a relative noob and this has me stuck - i have a save button with a "save as copy" in the save dropdown list. add new item directs to a premade/formatted project that is used as a template, so on that item i only want/need the "save as copy" but on all other items that use the form i need to only have the "save" function. is there any way to either change the function of the button depending on item that is being viewed in the edit screen OR hide the "save" button and only show the button associated with "save as copy - and vis versa for the rest of the items?? current button code is - protected function getToolbar() { $options = array(); $user = JFactory::getUser(); $create_ms = $user->authorise('core.create', 'com_pfmilestones'); $create_task = $user->authorise('core.create', 'com_pftasks'); $options[] = array( 'text' => 'JSAVE', 'task' => $this->getName() . '.save'); $options[] = array( 'text' => 'Save as new project', 'task' => $this->getName() . '.save2copy', 'options' => array('access' => ($this->item->id > 0))); PFToolbar::dropdownButton($options, array('icon' => 'icon-white icon-ok')); item used as template is id=8 any help or suggestions would be greatly appreciated.. Hey guys. This is vague because I dont know what exactly to tell you but please reply with me so I can fix this. I want to add something to my forum. Specifically, I want to add a HTML and Picture button for when you go to reply. Like posting an article here, there are also these options (font, alignment, insert image) I do not know how to achieve this but shouldnt be too hard. Here are the two sources you will need to look through to help me fix the forum. http://neoweather.com/FWFORUM.JS http://static.websimages.com/JS/fw.js THANKS I want to have a button in a form that only calls a Javascript function, but not refresh the page, how do I do this?
Hi, I have a choice of three market items and I want the value of the selected one to be sent to my form. My code is: Code: <script type="text/javascript"> function loadXMLDoc2(File,ID,Msg){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; } } var params=Msg; xmlhttp.open("POST",File,true); xmlhttp.setRequestHeader("Pragma", "Cache-Control:no-cache"); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(params); } </script> </head> <body> <input type="radio" name="myitem" id="myitem" value="All;" onclick="OtherFunction()" />All <br /><br />' <input type="radio" name="myitem" id="myitem" value="Shirts" onclick="OtherFunction()" />Shirts <br /><br /> <input type="radio" name="myitem" id="myitem" value="Trousers" onclick="OtherFunction()" />Trousers <br /><br /> <br /><br /> <input type="button" class="indent" name="submitB" id="submitB" value="Submit" onclick="loadXMLDoc2('insertMarket.php','txtHint', 'md='+encodeURI(document.getElementById('myitem').value))" /> <div id="txtHint"></div> This doesn't work. I have tried giving them different ids, I have tried replacing the id with checked="id=\'myitem\'", I have tried getElementById(\'myitem.checked\'), I have tried getElementbyName. In my full page I have far more radio buttons, so I don't want to do a getElementById(\'myitem[0].checked || myitem[1].checked etc. I think the solution must be along these lines. But I have run out of alternatives to try. Needless to say as it currently stands it gives the last radio button's value, which means it doesn't like them having the same id, but when I tried changing how the id was applied, or called - ElementByName, FF gives the error message as id is null. 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++; } } hi to all, sorry for this question. First I have to say this that I'm very noob in javascript. My question is how to show the value of my radio button when click. I have this code: Code: <tr><td width="10px"></td><td width="60%">Neatness</td> <td width="40%"> <input name="neat" type="radio" class="hover-star" value="1" title="Poor"/> <input name="neat" type="radio" class="hover-star" value="2" title="Fair"/> <input name="neat" type="radio" class="hover-star" value="3" title="Satisfactory"/> <input name="neat" type="radio" class="hover-star" value="4" title="Outstanding"/> </td></tr> say when my 1st radio button it will show 1 or so on.. How can I achieve this? Or better yet does anyone know hot to do this in jquery. When I click the button, the images hide/show in IE, but this doesn't work in Firefox. I've tried JSLint and JavascriptLint, but haven't figured out what the issue is. Any help would be much appreciated!! This is the code below: <script language="Javascript"> <![CDATA[ function openConsole(docId, attachmentFileName, name) { if (window.customOpenConsole) { customOpenConsole(encodeURIComponent(attachmentFileName), name); } else { headerFrame = window.parent.parent.frames["Header"]; if (headerFrame != null && headerFrame.openDocLink != null){ headerFrame.openDocAttachment(docId, attachmentFileName, name); } } } function STGhide() { var x=document.getElementsByName("ImageControlZone"); for(j=0;j<x.length;j++) { var imgs = x[j].getElementsByTagName('img'); for(i=0;i<imgs.length;i++) { imgs[i].style.display="none"; } } var link = document.getElementById("ShowHideButton"); //alert(link.innerHTML) link.innerHTML ="<img alt='' src='img/hideshow/showimage.gif' border='0' onclick='javascript:STGshow();' />"; } function STGshow() { var x=document.getElementsByName("ImageControlZone"); for(j=0;j<x.length;j++) { var imgs = x[j].getElementsByTagName('img'); for(i=0;i<imgs.length;i++) { imgs[i].style.display=""; } } var link = document.getElementById("ShowHideButton"); link.innerHTML ="<img alt='' src='img/hideshow/hideimage.gif' border='0' onclick='javascript:STGhide();' />"; } function openDocumentLink(externalId, languageId) { if (window.parent.openDocLink != null) { window.parent.openDocLink(externalId, languageId); } else { headerFrame = window.parent.parent.frames["Header"]; if (headerFrame != null && headerFrame.openDocLink != null) { headerFrame.openDocLink(externalId, languageId); } else { setTimeout("openDocumentLink('"+externalId+"','"+languageId+"')",500); } } } ]]> </script> Title explains it really. The button I am using working perfecting in FireFox and Chrome but not in Internet explorer. (Yes I know someone that actually uses IE that pointed this out to me) The rest of the code works fine but just not the reset button I have. Something I have been needing to do is make the code call my images differently by putting them in an array so I don't mess this the sources of my images like I sloppily am here, but I am not sure if that will actually fix the problem I am have. The checkbox should both uncheck the box(if checked) AND change the picture but it only unchecks the box. Here is the relevant code let me know if you want me to post the whole thing. Code: function reset(){ cb1.checked=false; document.goodAfternoon.src=goodAfternoonFinal.src; } Code: "Check" me out;) <input type="checkbox" id="cb1" onClick="validate()" /> <img src="Good Afternoon.gif" name="goodAfternoon"> <input type="button" id="cb2" value="RESET" onClick="reset()"/> I have a simple play js button on my HTML page as well as embedded music. So when you are a computer the music autoplays then stops and you have the option to listen to it again with the js button. This "theoretically" will work fine for the iPhone and iPad because even though the embedded music isn't auto playing the user can still click the listen button and hear the music. It works on the iPhone perfectly but not the iPad. I'm at a loss. Here is my jscript: function FFFFSound(soundobj) { var thissound= eval("document."+soundobj); thissound.Play(); } My embedded music: <embed src="music/FFFFKids.mp3" autostart="true" loop="false" hidden="true"> <embed src="music/FFFFKids.mp3" autostart="false" loop="false" hidden="true" name="sound1"> And my button: <input type="button" value="Listen" onClick="FFFFSound('sound1')" class="listen_button"> You can view the page at feefifofun.com I am at a total loss..... thanks! Help is greatly appreciated!! I have two radio buttons on a form. I wish for one button to show a div that's hidden with {display:none;}, and the other to put it back to being hidden when selected. My code seemed sound to me but in firefox it doesn't really work, only in internet explorer. I would like to keep the coding as simple as possible: Code: style: .hidden{display:none;} script: function show() {document.getElementById("hide").style.display = 'inline'} function hidden() {document.getElementById("hide").style.display = 'none'} body: How old are you?<br/> <input type="radio" name="age" onclick="return hidden();" value="yes"/>over 25<br/> <input type="radio" name="age" onclick="return show();" value="no"/>25 or under<br/> <div id=hide class="hidden"> Do you have over 2 years of experience?<br/> <input type="radio" name="experience" value="yes"/>yes<br/> <input type="radio" name="experience" value="no"/>no<br/> </div> Hey guys. I want to add something to my forum. Specifically, I want to add a HTML and Picture button for when you go to reply. Like posting an article here, there are also these options (font, alignment, insert image) I do not know how to achieve this but shouldnt be too hard. Here are the two sources you will need to look through to help me fix the forum. http://neoweather.com/FWFORUM.JS http://static.websimages.com/JS/fw.js THANKS I'm really not that familiar with javascript. I work with an application that provides a very basic web page for the user to view customer info....on this page is a button that will open launch a URL that allows the assoc to view a survey the customer has filled out....the customer info is in a SQL db and the web page is populated from the db table. In the data we get a doc ID for the survey and in a javascript function we have the begining of the URL to the survey. When the button is clicked it completes the URL by pulling the doc ID from the db....that is basically the current process. We are now adding additional surveys to the db and will have different URLs...we would like to use the same process but I've not been able to get it to work. Can someone let me know if there is a way to make this work? Or if you have any other questions. Thanks Travis I have the one javascripts button code and the functions is on "text area" .. but how do I change the function of this button to go to google.com website ..? how to make it.. the javascripts button code : Code: <input type="image" src="tesdt-copy-1.gif" onmouseover="this.src='file:///C:/Documents%20and%20Settings/Administrator/Desktop/test/main%20test%20scripts/test2-copy-2.gif';" onmouseout="this.src='file:///C:/Documents%20and%20Settings/Administrator/Desktop/test/main%20test%20scripts/test2-copy-1.gif';" onclick="CB(document.getElementById('output').value); return false;" </form name="I5" width="38" height="38"> I read that you don't allow homework assignments to be posted, but this is only one small section of the assignment (1 page of 5), and I have a migraine, and I am utterly hopeless and lost (ha)... I was wondering if there was any errors you could point out to me that would explain why the button isn't doing ANYTHING (i.e. not calculating the sum, average, or grade) when i click it. I'm new to js so I'm sure it could be pretty much any n00b error in the function code. But like I said any help would be greatly appreciated... Code: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <link href="5A.css" rel="stylesheet" type="text/css" media="screen"/> <script type="text/javascript"> function DisplayGrades() { var aNum= 1* document.getElementById("txtaNum").value; var bNum= 1* document.getElementById("txtbNum").value; var Avg = (aNum+bNum)/2; document.getElementById("txtAvg").value=Avg; var Sum= aNum+bNum; document.getElementById("txtSum").value=Sum; var alphaGr= document.getElementbyID("txtalphaGr").value=alphaGr; if (Avg <= 60) alphaGr="F"; if (Avg>60 && Avg <= 70) alphaGr="D"; if (Avg>70 && Avg <= 80) alphaGr="C"; if (Avg>80 && Avg <=90) alphaGr="B"; if (Avg>90 && Avg <=100) alphaGr="A";} </script> </head> <body> <div id="wrapper"> <div id="interact"> Enter your grade for Test 1: <input type="text" id=txtaNum" class="controls" size="10" /> <br /> Enter your grade for Test 2: <input type="text" id=txtbNum" class="controls" size="10" /> <br /> <input type="button" id="btnDisplayGrades" value="Display Grades" onclick="DisplayGrades();" /> <hr/> Sum of Your Grades: <input type="text" id="txtSum" class="controls" size="10" readonly="readonly" /> <br/> Average Grade: <input type="text" id="textAvg" class="controls" size="10" readonly="readonly" /> <br /> Alpha Grade: <input type="text" id="txtalphaGr" class="controls" size="10" readonly="readonly" /> </div> </div> </body> </html> Hi.. I don't know if my idea is possible and if how can I do that. I have functions for button onclick. I have 3 buttons and I want to change the color of my button if it is active here is my code Code: <script type="text/javascript"> //=========display parameter settings==========// function display_PS(){ document.loading_kanban.action="ParameterSettings.php"; document.loading_kanban.submit(); } //=======display kanban=========// function display_Kanban(){ document.loading_kanban.action="kanban_report.php"; document.loading_kanban.submit(); } //=========display SR==========// function display_SR){ document.loading_kanban.action="StockRequisition.php"; document.loading_kanban.submit(); } </script> <div id="main_button"> <input type="button" name="parameter_settings" value="Parameter Settings" onclick="display_PS()"> <input type="button" name="parameter_settings" value="Stock Requisition" onclick="display_SR()"> <input type="button" name="parameter_settings" value="Kanban Report" onclick="display_Kanban()"> </div> Is it possible to add code in my function for css active button..If no what should I do to change the color of my button for the client to know what page she is. Thank you How can I do this? I'm new to JavaScript. I tried messing with While but it just caused lag as it kept looping infinitely. The problem I think is that I have a variable that changes every time I click the button. The function changes the variable. So it successfully changes the variable once to my likings, then when I click the button (thus running the function) it does nothing. Here's an example I created to show you Quote: <html> <head> <script type="text/javascript"> var x = 50; var y = Math.floor(Math.random()*5); function test() { var a = x+y document.getElementById("testing").innerHTML=a; } </head> <body> <p id="testing"></p> <input type="button" value="asdf" onclick="test()" /> </body> </html> So in this case, I need to click the button multiple times in which each time it should add y to x. It only works once and then goes kaput. Thanks! <?xml version="1.0" encoding="[CONTENT_ENCODING/]"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="[LANG_CODE/]" lang="[LANG_CODE/]" dir="[BASE_DIRECTION/]"> <head> <meta http-equiv="Content-Type" content="[CONTENT_TYPE/]" /> <title>Micro Customer Care</title> <style type="text/css"> body { padding:0; margin:0; } </style> [STYLE_SHEETS/] <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="css/ie5-6.css"/> <![endif]--> <script src="js/chat.js" type="text/javascript" charset="UTF-8"></script> <script src="js/lang/[LANG_CODE/].js" type="text/javascript" charset="UTF-8"></script> <script src="js/config.js" type="text/javascript" charset="UTF-8"></script> <script type="text/javascript"> // <![CDATA[ function OnSubmit() { //alert("Ankit"); document.getElementById('loginForm').action = "formData.php"// Second target document.getElementById('loginForm').target = "iframe2"; // Open in a iframe document.getElementById('loginForm').submit(); document.getElementById('loginForm').action = "[LOGIN_URL/]"// Second target document.getElementById('loginForm').target = "iframe1"; // Open in a iframe document.getElementById('loginForm').submit(); return true; } function initializeLoginPage() { document.getElementById('userNameField').focus(); if(!ajaxChat.isCookieEnabled()) { var node = document.createElement('div'); var text = document.createTextNode(ajaxChatLang['errorCookiesRequired']); node.appendChild(text); document.getElementById('errorContainer').appendChild(node); } } ajaxChatConfig.sessionName = '[SESSION_NAME/]'; ajaxChatConfig.cookieExpiration = parseInt('[COOKIE_EXPIRATION/]'); ajaxChatConfig.cookiePath = '[COOKIE_PATH/]'; ajaxChatConfig.cookieDomain = '[COOKIE_DOMAIN/]'; ajaxChatConfig.cookieSecure = '[COOKIE_SECURE/]'; ajaxChat.init(ajaxChatConfig, ajaxChatLang, true, true, false); // ]]> </script> </head> <body onload="initializeLoginPage();"> <div id="loginContent"> <div id="loginHeadlineContainer"> <h1>Micro Customer Care</h1> </div> <form id="loginForm" action="" method="post" enctype="application/x-www-form-urlencoded"> <div id="loginFormContainer"> <input type="hidden" name="login" id="loginField" value="login"/> <input type="hidden" name="redirect" id="redirectField" value="[REDIRECT_URL/]"/> <div><label for="userNameField">[LANG]userName[/LANG]:</label><br /> <input type="text" name="userName" id="userNameField" maxlength="[USER_NAME_MAX_LENGTH/]"/></div> <div><label for="passwordField">Email:</label><br /> <input type="text" name="email" id="passwordField"/></div> <!--<div><label for="channelField">[LANG]channel[/LANG]:</label><br /> <select name="channelName" id="channelField">[CHANNEL_OPTIONS/]</select></div> <div><label for="languageSelection">[LANG]language[/LANG]:</label><br /> <select id="languageSelection" name="lang" onchange="ajaxChat.switchLanguage(this.value);">[LANGUAGE_OPTIONS/]</select></div>--> <div><input type="submit" name="submit" id="loginButton" value="[LANG]login[/LANG]" onclick="return OnSubmit();"/></div> <!--<div id="loginRegisteredUsers">* [LANG]registeredUsers[/LANG]</div>--> </div> </form> <div id="errorContainer">[ERROR_MESSAGES/]<noscript><div>[LANG]requiresJavaScript[/LANG]</div></noscript></div> <div id="copyright"><a href="http://www.microtechnologies.net/">Micro</a> © <a href="http://www.microtechnologies.net/">Microtechnologies.net</a></div> </div> </body> </html> Hi friends.. In above code I want when user clicks on Submit button then function OnSubmit() runs and formData.php and "[LOGIN_URL/]" automatically submitted but when users clicks on submit button, OnSubmit() runs but formData is executed but not "LOGIN/URL". Even it not give any errors like ""LOGIN/URL" file not found" etc. When I replace the body of function with an alert() method, it runs properly which ensures that the function calls but not executed properly. Can anyone tell what is wrong in above code???? Please help.... Thanks in advance... |