Forum Moderators: open

Message Too Old, No Replies

form returning undefined value

undefined data

         

bbm_builder

11:06 pm on Feb 9, 2006 (gmt 0)

10+ Year Member



Thanks for the help last time, can I ask one more Javascript question? I am trying to send a program to a cgi script after data verification through Javascript. However, the value for my radio button portion is returning an undefined value and I can't figure out why. When I submitted the form without the Javascript it worked perfectly, but the Javascript portion seems to be causing some issues. Can anyone take a look at my script and suggest what I might be doing wrong? Thanks.

<script type = "text/javascript"><!--

function checkforms() {
with(document) {

var checkName
var checkEmail
var checkSrc
var checkNewsltr
var itsOkay

itsOkay = 1;
checkNewsltr = verify.newsltr.value;
checkName = verify.name.value;
if (checkName == "")
{
alert ("Your name entry is not valid");
itsOkay = 0;
}

checkEmail = verify.email.value;
if (checkEmail == "")
{
alert ("You did not enter an email address");
itsOkay = 0;
}

checkSrc = verify.source.value;
if (checkSrc == "")
{
alert ("You did not identify a source");
itsOkay = 0;
}

if (itsOkay)
{
investors.name_info.value = checkName;
investors.email_info.value = checkEmail;
investors.source_info.value = checkSrc;
investors.newsltr_info.value = checkNewsltr;
investors.submit();
}
}
}

//-->
</script>

<form name="verify">
Name:<input type=text name="name" size="30"><br><br>

E-Mail Address:<input type=text name="email" size="30"><br><br>

How did you find this website? <select name="source">
<option value="">list source</option>
<option value= "search engine">Search Engine</option>
<option value= "web link">Web Link</option>
<option value= "friend/family member"> Friends/Family</option>
<option value= "written publication">Written Publication</option>
<option value= "other - list below">Other List Below</option></select><br><br>

Other Source:<input type=text name="other_source" size="30"> <br><br>

Can we add you to our Newsletter?
Yes<input type="radio" name="newsltr" value="yes" checked>
No<input type="radio" name="newsltr" value="no"> <br><br></font>

<input type=button name=button Value="View Plan" onclick="checkforms()">
</form>

<form action="http://mydomain.com/cgi-bin/info.cgi" method="post" name="investors">
<input type=hidden name=name_info value="">
<input type=hidden name=email_info value="">
<input type=hidden name=source_info value="">
<input type=hidden name=newsltr_info value="">
</form>

Bernard Marx

9:19 am on Feb 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I thought we sorted that out yesterday :)

The selected value for a group of radios can't be read directly from the name. We must look at each individual member. For groups with more element, we would normally loop through all until we find a checked radio, but here we know that if the first isn't checked, then the second one is.

checkNewsltr = verify.newsltr[0].checked? "yes":"no";

bbm_builder

3:40 pm on Feb 10, 2006 (gmt 0)

10+ Year Member



I think I am finally seeing the light. Thanks for the assist.