Subject: Database driven Dynamic radio buttons :URGENT
Posted By: srichary Post Date: 10/28/2004 8:41:18 AM
I am trying to make the radio button checked as the value is true
i am using the following code
  
<input name="occupation" type="radio" value="housewife" <%if occupation=rs("occupation") then response.write "checked" end if%>>

BUt  actually the radio button is not getting selected even if the value from the database is true.I am using ASP and SQL7.0
Reply By: bmains Reply Date: 10/29/2004 2:32:54 PM
What type is occupation, and I am guessing you are using a bit?

<input name="occupation" type="radio" value="housewife"
<%
if (occupation = cbool(rs("occupation"))) then
  Response.Write(" checked")
end if
%>
>

Brian
Reply By: happygv Reply Date: 10/30/2004 1:48:15 AM
srichary,

It would be better, if you could also post what the datatype that you use as OCCUPATION in the db, and may be post some sample data to be clear on that, before suggesting.

Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply By: srichary Reply Date: 10/30/2004 2:43:03 AM
Hi,
 I am using varchar(25) datatype for occupation.

thanks brian for the code.I tried ur code but gave me

type mismatch:'cbool'

cant get this right

Please somebod HElp

Reply By: happygv Reply Date: 10/30/2004 2:48:30 AM
I doubt if you store any value into "occupation" variable that is involved in the IF condition there.
Response.write "Occupation=" & occupation & "<br>"
Response.write "Recordset Occupation=" & rs("occupation")& <br>
Response.end
Try this code just above that radio button code and post the output here. Let see what comes in both the variable and Recordset.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply By: srichary Reply Date: 10/30/2004 4:09:24 AM
This was the output based on the code By Vijay G

Occupation=
Recordset Occupation=service


My ACtual form code is


<input name="occupation" type="radio" value="service" <%if occupation=rs("occupation") then response.write "checked" end if%>>
    Service
      <input name="occupation" type="radio" value="retired" <%if (occupation=trim(rs("occupation"))) then response.write "checked" end if%>>
    Retired
    <input name="occupation" type="radio" value="housewife" <%if (occupation=trim(rs("occupation"))) then response.write "checked" end if%>>
    House wife


Reply By: bmains Reply Date: 11/1/2004 7:46:48 AM
Hey, Try:

<% if lower(occupation) = lower(rs("occupation")) then

Brian
Reply By: srichary Reply Date: 11/1/2004 8:18:46 AM
Hey brian ,
  I tried your code but its giving me this error:

Type mismatch: 'lower'

thanks


Reply By: happygv Reply Date: 11/1/2004 1:23:50 PM
That should have been LCase(), instead of LOWER, in VBScript.

But as I doubted, Srichary, doesn't seem to assign any value to the OCCUPATION variable. So that doesn't always match with the rs("Occupation")'s value. I believe on top of this page, somwhere it should be written as
occupation = Request.Form("Occupation")
which seems to be missing. Can you confirm if and where you assign the value of OCCUPATION that is used on the left-hand-side in the IF statement?

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply By: srichary Reply Date: 11/2/2004 2:52:47 AM
THanks Vijay ,
   THis code worked really well .Its as if a dating virgin women and u are happy at the 10th day.Anyways thanks....
  
  I have a new problem catching the variables generated for the simple purchase list.
  Actualy i have a form with a check box(for selcting the product)
then i have a listbox containg language list for that produt and then a textbox for entering the quantity.
  All these are generated dynamically and are coming from database

 My problem is during submit i cannot access the correct checkbox values and the corresponding listbox values.
  CAn you tell me the logic and the problem
thanks

Reply By: happygv Reply Date: 11/2/2004 3:52:55 PM
Hi Srichary,

I am not sure if that would take 10 days to feel happy, but I can understand how happy you would have felt.

BTW, it would be better if you could post some part of the code related to that form fields that you mentioned, so as to understand how the UI would look and what is actually missing there.

Cheers!

_________________________
- Vijay G
Strive for Perfection

Go to topic 21556

Return to index page 726
Return to index page 725
Return to index page 724
Return to index page 723
Return to index page 722
Return to index page 721
Return to index page 720
Return to index page 719
Return to index page 718
Return to index page 717