Domain for sale - best offer |
|
Welcome Guest, our newest member is: maxxxmodels2009
/ / / /
JS question--what is wrong with my code?
It's an ASP intranet page, but I put up and HTML version at http://www.middletree.net/sample.html Find the listbox labeled Original Caller Name, with a checkbox near it. I have that checkbox checked when the page loads, and when it remains checked upon page submission, it should throw a javascript error if you don't select one of the names in there. The good news is, it gives you the error msg box. The bad news is, it still forwards you to the next page (which happens to be absent in my example; sorry) Thing is, I don't want it to submit; I want it to return false. That's where my question lies. Here's my JS code for that error msg(don't worry about the ExternalContactID; long story) if (frm.source.checked == true) { if (frm.InternalContactID.value == "") { alert("Please select the internal person who called with this problem."); frm.InternalContactID.focus(); return (false); } } else { if (frm.ExternalContactID.value == "SELECT") { alert("Please select the person who called with this problem."); frm.ExternalContactID.focus(); return (false); }
if (frm.source.checked){ if(!frm.InternalContactID.value) { alert("Please select the internal person who called with this problem."); frm.InternalContactID.focus(); return false; } // no "else" statement needed after "return" if (!frm.ExternalContactID.selectedIndex) { alert("Please select the person who called with this problem."); frm.ExternalContactID.focus(); return false; } } //I'm assuming that "ExternalContactID" is a select menu, if its selectedIndex is zero, it means that the header (e.g. "Please Select") is selected. if (!frm.ExternalContactID.selectedIndex) is the same as: if (frm.ExternalContactID.selectedIndex==0) Mick middletree wrote: > It's an ASP intranet page, but I put up and HTML version at > http://www.middletree.net/sample.html > > Find the listbox labeled Original Caller Name, with a checkbox near it. > I have that checkbox checked when the page loads, and when it remains > checked upon page submission, it should throw a javascript error if you > don't select one of the names in there. The good news is, it gives you the > error msg box. The bad news is, it still forwards you to the next page > (which happens to be absent in my example; sorry) > > Thing is, I don't want it to submit; I want it to return false. That's where > my question lies. > > > Here's my JS code for that error msg(don't worry about the > ExternalContactID; long story) > > if (frm.source.checked == true) { > if (frm.InternalContactID.value == "") > { > alert("Please select the internal person who called with this > problem."); > frm.InternalContactID.focus(); > return (false); > } > } > else { > if (frm.ExternalContactID.value == "SELECT") > { > alert("Please select the person who called with this problem."); > frm.ExternalContactID.focus(); return (false); > } > >
Dreamweaver: what am i doing wrong? (replies 6) Windows XP Help: same question i just sent wrong e mail addre... (replies 1) Fireworks: what is wrong with this software!!!! (replies 7) Dreamweaver: what did i do wrong???? (replies 4) Photoshop: color is wrong (replies 3) |



Linear Mode