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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically checking a checkbox from value

Status
Not open for further replies.
Mar 7, 2001
14
US
I have a situation where I want to get a team ID that has been modified. The user is provided with a list of teams and then a radio group showing assigned/unassigned, and then a submit value. Internally I have a hidden checkbox for each team holding the groupname "TeamID" and the value holding the actual team identifier:

<input type=&quot;checkbox&quot; name=&quot;TeamID&quot; value=&quot;<%=TeamInfo(&quot;teamid&quot;)%>&quot; style=&quot;visibility: hidden&quot;>

I am pursuing it this way so I can retrieve these values more easily on the submission of the form:

dim Item
for each item in Request.Querystring(&quot;TeamID&quot;)
' Do OP
next

When a user selects the &quot;Assign/Unassign&quot; in the radio box, I want to check the corresponding checkbox so I know the user has modified this team. I have an onclick even that passes the team ID to a subroutine.

At this point I stumble. How do I set the checkbox (e.g. Document.TheForm.TeamID.Checked = &quot;True&quot; ) where the checkbox value matches the TeamID sent?

I've tried using the Eval function, but I can't seem to get it working correctly.

Thanks :)
 
I'm not sure about VB Script, but using Java Script;

<SCRIPT>
function checkTheBox(checkbox_name) {
document.form_name.checkbox_name.checked = true;
}
</SCRIPT>

<form>

<input type=checkbox name=check1>
<input type=radio name=radio1 onClick=checkTheBox(this.form.check1);>

</form>
 
Thanks for the response. I actually figured it out with VBScript. I do an onclick event in the radio box:

onclick=&quot;do_statchange(<%=TheTeamID%>)

In the VBScript subroutine, I do this:

sub do_statchange(TheTeamID)
for i = 0 to AssignTeams.TeamID.Length -1
if cint(AssignTeams.TeamID(i).Value) = cint(TheTeamID) then
AssignTeams.TeamID(i).Checked = &quot;True&quot;
end if
next
end sub


This works like a champ!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top