populating a check box w/ asp

Results 1 to 2 of 2

Thread: populating a check box w/ asp

  1. #1
    Join Date
    Dec 1969

    Default populating a check box w/ asp

    I have an access table that (thanks to help from people on this list) is now properly receiving values inserted from a check box in an html form.<BR><BR>but now i have another problem. when i load the same html form again, i want it to fill in the check boxes with the same values that the underlying access datatable record has. this way the form can double as an update form in addition to just an insert form.<BR><BR>what&#039;s more, i have (for my own reasons) translated the values from the original form from "on" and "off" to "Y" and "N" in the access table that stores the record. i made that translation in the script that processes the form.<BR><BR>so my challenge in the script for this update form is to 1.) get the value from the access table and 2.) translate that value into a format that the html checkbox will read before 3.) populating the checkbox with the right value.<BR><BR>here is a relevant summary of what i have so far, which does not work:<BR>-----------------------------------------------------------------<BR>&#039; populate CenterID (done correctly in this case, w/ value from datatable)<BR>CenterID = Request( "pid" )<BR><BR>&#039;create database connection (works, but omitted here 4 brevity)<BR><BR>&#039; create recordset<BR>Set RecordSet = Server.CreateObject( "ADODB.Recordset" )<BR>RecordSet.ActiveConnection = Conn<BR>RecordSet.CursorType = 3<BR>RecordSet.Open "SELECT * FROM TraditionSummary WHERE CenterID=" & CenterID<BR>IF NOT RecordSet.EOF THEN<BR>&#039; populate all the variables and translate their values like this one is done:<BR><BR>Kripalu = RecordSet( "Kripalu" )<BR> IF Kripalu = "N" THEN<BR> Kripalu = "off"<BR> ELSEIF Kripalu = "Y" THEN<BR> Kripalu = "on"<BR> END IF<BR>&#039; the rest of the variables are then handled identically<BR>&#039; Close the Recordset<BR> RecordSet.Close<BR>&#039; html page formatting code<BR>&#039; html form code, with all check boxes that follow the following model:<BR><BR>&#060;input type="checkbox" name="Kripalu" size="50" maxlength="50" &#060;% IF Kripalu = "on" THEN %&#062; value="checked" &#060;% END IF %&#062; &#062;<BR><BR>&#039; html for rest of page<BR>-----------------------------------------------------------------<BR>can anyone show me how to fix this so that i get the checkboxes populated properly? right now they are all coming up empty, even though i have checked and i know for certain that the specific record i am pulling up has "Y" recorded in the access table for the Kripalu field i am highlighting above

  2. #2
    Join Date
    Dec 1969

    Default RE: populating a check box w/ asp

    Well if you want the checkbox to show up checked based on the variable the value should not equal checked. It should be like this:<BR><BR>&#060;input type="checkbox" name="Kripalu" size="50" maxlength="50" value="AnythingYouWwant" &#060;% IF Kripalu = "on" THEN %&#062; checked&#060;% END IF %&#062; &#062;<BR><BR>the value can be anything you put in there, such as info from your DB. Whether or not it is checked determines if what is in value gets passed to the next page.

Posting Permissions

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