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

set radio button checked value

Status
Not open for further replies.

JanS

Technical User
Feb 21, 2001
77
AU
Hi,

I am using VBScript and need to be able to set a group of radio buttons to checked or not checked based on data returned from the database.

I can set "checked" to true or false if the radio buttons are named differently, but once I name them all the same (ie create a group) the page will not load.

What I am trying to do is something like this:

select case rsData("type")
case "P"
window.CriteriaPg.rType[0].checked = true
window.CriteriaPg.rType[1].checked = false
case "S"
window.CriteriaPg.rType[0].checked = false
window.CriteriaPg.rType[1].checked = true
end select

The radio buttons are created using:

<INPUT name=rType type=radio value=P>Primary
<INPUT name=rType type=radio value=S>Secondary

Any ideas what I am doing wrong?

Thanks in advance
jan
 
With VBScript I just take the value from the DB (stored as 1 or 0 and run a little if statement while splitting the response.write that creates the box...

response.write &quot;<input type = checkbox name = myfield&quot;
if objRS(&quot;Field&quot;) = 1 then
response.write &quot;CHECKED>&quot;
else
response.write &quot;>&quot;
end if

NOTE: I did find that the word CHECKED does need to be in capitals to mark the option as checked.

hth
Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Thanks for your reply. These things are never as easy as I think they are going to be!

I am actually creating all the objects on the page as HTML and calling a vbscript sub from the <Body> tag, using 'onload', to connect to the database and retrieve the record I wish to display.

The value of the &quot;type&quot; field can be many and varied, no way to make it 0 or 1. I need to check for all options and set the appropriate radio button.

Any other ideas??

thanks
jan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top