Hello.
The following code has been shortened just to the main area. It's a form
validation problem. When I hit 'submit', the form is supposed to check if a
selection out of the drop down menu has been selected. If not then it's
suppose to generate an error message.
The question is with the variables and arguments passed to the function. I
already checked with Firebug, and this variable:
var sel_opt = the_sel.options[the_sel.selectedIndex];
is working...'sel_opt' has a value of 'option'..so I'm guessing that it's
defined..because if it wasn't then it would say 'undefined'.
If it is defined then why isn't my code checking if something was selected?
....
function attachHandlers(){
var the_button = document.getElementById("my_button");
the_button.onclick=function(){return checkFormFields();};
var radio_buttons = document.getElementsByName("beauty");
for (var i=0; i < radio_buttons.length; i++)
{
if (i 0)
{
radio_buttons[i].onclick=removeRadioOpts;
}
else
{
radio_buttons[i].onclick=addRadioOpts;
}
}
var chkbox_sel = document.getElementById("checkchoice");
chkbox_sel.onclick=addCheckOpts;
}
....
function checkFormFields()
{
.....
var sel_opt = the_sel.options[the_sel.selectedIndex];
....
}
....
correct=checkSelOpts(sel_opt, error);
if (!correct)
{
error_mes += errors[error.val] + '<br>';
sel_opt.focus();
}
....
....
function checkSelOpts(city_opts, error){
if (city_opts!= -1 && city_opts.value !="none")
{
return true;
}
error.val=4;
return false;
}
....
Hopefully you can follow this..
--
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forum...cript/200810/1