Best way to populate Radio Buttons in an ASP Page

Results 1 to 5 of 5

Thread: Best way to populate Radio Buttons in an ASP Page

  1. #1
    Join Date
    Dec 1969
    Posts
    552

    Default Best way to populate Radio Buttons in an ASP Page

    I have an ASP page where I exec a Stored Proc.<BR>The values returned I want to populate in Radio buttons on my page for users to read/update.<BR>What is the best way to indicate that a button is checked?<BR><BR>&#060;form...&#062;<BR>&#060;input type="Radio" name ="test" value="0"&#062;<BR>&#060;input type="Radio" name ="test" value="1"&#062;<BR>&#060;input type="Radio" name ="test" value="2"&#062;<BR>...<BR>&#060;/form&#062;<BR><BR><BR>Thanks -<BR>Tim

  2. #2
    Join Date
    Dec 1969
    Posts
    73

    Default RE: Best way to populate Radio Buttons in an ASP Page

    Try this: Hope this works :)<BR><BR>&#060;% do while not rslist.eof %&#062;<BR>&#060;input type="Radio" name ="test" value="&#060;% =rslist("Value")%&#062;"&#062;<BR>&#060;%<BR>rsLis t.MoveNext <BR>loop<BR>%&#062;

  3. #3
    Join Date
    Dec 1969
    Posts
    552

    Default RE: Best way to populate Radio Buttons in an ASP Page

    Thanks, but I do not think this will work?<BR><BR>Here is my form -<BR>&#060;form...&#062;<BR>&#060;input type="Radio" name ="test" value="0"&#062;You have a value of "0"<BR>&#060;input type="Radio" name ="test" value="1"&#062;...of "1"<BR>&#060;input type="Radio" name ="test" value="2"&#062;...of "2"<BR>...<BR>&#060;/form&#062;<BR><BR>I need to have all options available for the user to select. The case may exist where the value already exists in the DB. IF this is the case, I want my users to see what they currently have selected in the DB and allow them to update.<BR><BR>Any help would be appreciated!

  4. #4
    Join Date
    Dec 1969
    Posts
    168

    Default RE: Best way to populate Radio Buttons in an ASP Page

    &#060;%<BR>&#039v is the value of the check box<BR>&#039db is what is in your db i.e. rs.fields("test").Value<BR>&#039if v=db the function returns checked, otherwise an empty string<BR>&#039In the example below "2" is the value in the DB<BR><BR>Function ischecked(v,db)<BR>If db=v then <BR>ischecked=" checked"<BR>else ischecked=""<BR>end if<BR>end function<BR>%&#062;<BR><BR>&#060;input type="radio" name="test" value="1"&#060;%=ischecked("1","2")%&#062;&#062;1& #060;p&#062;<BR>&#060;input type="radio" name="test" value="2"&#060;%=ischecked("2","2")%&#062;&#062;2& #060;p&#062;<BR>&#060;input type="radio" name="test" value="3"&#060;%=ischecked("3","2")%&#062;&#062;3& #060;p&#062;<BR><BR>Hope this helps.. Cheers!


  5. #5
    Join Date
    Dec 1969
    Posts
    552

    Default THANKS - Best way to populate Radio Buttons in an ASP Page

    That works great and is just what I needed, for I needed to re-use that in other radio buttons in the form.<BR><BR>I really appreciate it<BR><BR>Thanks!!<BR><BR>Tim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •