gthelp.com

Domain for sale - best offer

Welcome Guest, our newest member is: maxxxmodels2009  
User Name Password Save?
 JS question--what is wrong with my code?

Post New Content Post New Content  

Default 

JS question--what is wrong with my code?

  #1  
Old July 15th, 2004, 06:23 PM
Guest
 
Posts: n/a

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);
}





Default 

Re: JS question--what is wrong with my code?

  #2  
Old July 15th, 2004, 06:23 PM
Guest
 
Posts: n/a


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);
> }
>
>



 

Post New Content Post New Content  

Display Modes
Similar Titles
Dreamweaver: what am i doing wrong? (replies 6)
Dreamweaver: what did i do wrong???? (replies 4)
Photoshop: color is wrong (replies 3)


Staff - Contact Us - Main - Archive - Technorati Profile - Top  
vBulletin Software: Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Page generated in 0.07661 seconds with 11 queries