Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > BOOK: Beginning ASP 3.0
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 28th, 2004, 08:41 AM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Database driven Dynamic radio buttons :URGENT

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
  #2 (permalink)  
Old October 29th, 2004, 02:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
  #3 (permalink)  
Old October 30th, 2004, 01:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
  #4 (permalink)  
Old October 30th, 2004, 02:43 AM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

  #5 (permalink)  
Old October 30th, 2004, 02:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

I doubt if you store any value into "occupation" variable that is involved in the IF condition there.
Code:
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
  #6 (permalink)  
Old October 30th, 2004, 04:09 AM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


  #7 (permalink)  
Old November 1st, 2004, 08:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey, Try:

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

Brian
  #8 (permalink)  
Old November 1st, 2004, 09:18 AM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey brian ,
  I tried your code but its giving me this error:

Type mismatch: 'lower'

thanks


  #9 (permalink)  
Old November 1st, 2004, 02:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
Code:
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
  #10 (permalink)  
Old November 2nd, 2004, 03:52 AM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
validation in radio buttons MunishBhatia ASP.NET 2.0 Professional 5 December 11th, 2007 11:15 AM
Radio buttons disappear JoeBob49 ASP.NET 2.0 Basics 2 November 27th, 2006 09:57 AM
How to use the radio buttons? ben_VB VB.NET 2002/2003 Basics 1 January 18th, 2005 12:29 PM
Radio buttons over email??? morpheus Classic ASP Basics 5 April 20th, 2004 01:21 PM



All times are GMT -4. The time now is 11:53 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.