Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why am I still getting prompted on Validation

Status
Not open for further replies.

ASPSQLVB

Programmer
Nov 26, 2006
2
US
Guys,

I am trying to proceed to the next page but, cannot because I cannot get passed the Validation Prompt "Select a Fish Angler". Wondering Why ?


var found_it //<EM>initial value is null because we gave it no other value
for (var i=0;i<document.form1.CarpAnglerFishId.length; i++)
{
if (document.form1.CarpAnglerFishId.checked)
{
found_it = document.form1.CarpAnglerFishId.value //set found_it equal to checked button's value
}
}


if(found_it != null && document.form1.CarpAnglerFishId.value != "") //<EM>if found_it is NOT equal to null, a button HAS been checked
{
document.form1.submit();
return true;
}
else
{
alert("Select a Fish Angler");
return false;
}


Response.Write("<td align=""left"">&nbsp;&nbsp;&nbsp;<input type=""radio"" name=""CarpAnglerFishId"" value='" & RS1("FishId") & "'>&nbsp;&nbsp;<font color=""white""><font color=""white"" size=""4"">" & RS1("FirstName") & " " & RS1("LastName") & "</font></td>" & vbCrlf)
 
When I type this in Visual Interdev ...
document.form1.CarpAnglerFishId.value...

the CarpAnglerFishId name does not appear in the the little pop up box of element names. Seems the name CarpAnglerFishId is not being recognized.

When I type this in Visual Interdev ...
document.form1.Lbs.value...

the Lbs name appears in the the little pop up box of element names.

I am assumming this is the problem ?.....


 
[1] document.form1.CarpAnglerFishId is a collection and as such its value is "undefined".
[2] Just an aside, you have document.form1.submit() line. Maybe the function is not a onsubmit handler? otherwise you may not need that line with "return true" following? This depends on how you really script that thing.
[3] found_it is not fully used defined as checked value. You can as well simply set it to true if a radio button is found to be checked.
[tt]
var found_it //<EM>initial value is null because we gave it no other value
for (var i=0;i<document.form1.CarpAnglerFishId.length; i++)
{
if (document.form1.CarpAnglerFishId.checked)
{
found_it = document.form1.CarpAnglerFishId.value //set found_it equal to checked button's value
[blue]break;[/blue]
}
}

if([blue]!found_it[/blue]) //<EM>if found_it is NOT equal to null, a button HAS been checked
{
document.form1.submit();
return true;
}
else
{
alert("Select a Fish Angler");
return false;
}
[/tt]
 
Amendment
This line
> [tt]if([red]![/red]found_it)[/tt]
should, obviously?, be read like this.
[tt]if[highlight](f[/highlight]ound_it)[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top