[thelist] more loops... this time, javasctipt [SOLVED]
Brian Cummiskey
Brian at hondaswap.com
Tue Aug 23 14:33:05 CDT 2005
Hershel Robinson wrote:
> to access the ith q question where i is your loop variable. Another
> option is to use something like:
>
> theform.elements["q"+i]
I tried this method, Hershel, and she's golden :) Thanks :)
I kinda got my indexes "backwards" per standard with the i and j vars,
but it will work for now...
:)
//-------------------------------------------------------------------
function valid() {
var theform = document.getElementById("frmdefault");
for (j=1; j<29; j++)
{
for (i=0; i<theform.elements["q"+j].length; i++)
{
if (theform.elements["q"+j][i].checked)
{
if (theform.elements["q"+j][i].value == "NO")
{
if(theform.elements["q"+j+"_comments"].value == "")
{
alert("Comments required for Q"+j+" when NO is selected");
theform.elements["q"+j+"_comments"].focus();
return false;
}
}
}
}
}
theform.method="post";
theform.action="process.asp";
theform.submit();
}
//----------------------------------
Doug R wrote:
> Couldn't you call the function on each change, passing variables to the
> script then? So have an onChange event that will pass the question number,
> then if the selected index value is no, you pop up the alert then.
Doug, i think you didn't quite get what I was asking, or I didn't get
what you were answering with. I already have the check onsubmit() taken
care of... it was the loop that was the problem.
Thanks though
More information about the thelist
mailing list