473,508 Members | 3,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing Radio checked values

6 New Member
Hey there,

This may be an ASP question but i think it is more of a JS question.

I have a web form that i want to have database values loaded into. I have (and want) the form defaulting to unfilled. I now have it checking and updating most the fields if a recordId is added into the url using ASP. My problem lies in changing the radio values.

Here are some snipets of what I have to try to do this that isn't working.

-here is how i have the radios set up


Expand|Select|Wrap|Line Numbers
  1. Yes <input name="isDelegate" type="radio" value="yes" onclick="changeDiv('delegate','block')" /> 
  2.  
  3. No <input name="isDelegate" type="radio" value="no" onclick="changeDiv('delegate','none')" checked="checked" />



-here is the JS function

Expand|Select|Wrap|Line Numbers
  1. function setRadio(FormObj,stringvalue) {
  2.     If(stringvalue == 'yes'){
  3.         FormObj.isDelegate[0].checked = true;
  4.     }
  5.  
  6. }

-here is how i am calling it from ASP within the bottom of the form.
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Response.write("<script type='text/javascript'>")
  3. Response.write("setRadio(this.form,'" & GR("isDelegate") & "');") 
  4. Response.write("</script>")
  5. %>
that second line produces setRadio(this.form,'yes'); if printed out to the screen


I also tried testing it hardcoding the function call in JS as

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.        setRadio(this.form,'yes');
  3. </script>
And this didn't work either.

If anyone can help me it would be greatly appericiated!!
Jan 22 '09 #1
3 1579
acoder
16,027 Recognized Expert Moderator MVP
The problem is that "this" doesn't refer to what you probably think it does, so pass document.formName where formName is the name of the form.

If this is generated using ASP, why not just use ASP to set the checked property directly in the HTML code?
Jan 22 '09 #2
mileshenley
6 New Member
Thanks, i actually ended up doing it in ASP as you suggested. a much better idea!
Jan 22 '09 #3
acoder
16,027 Recognized Expert Moderator MVP
Yes, JavaScript is a wonderful language, but don't use it when it's not required.

Glad to hear that you got it working. See you around.
Jan 22 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9801
by: entoone | last post by:
I am able to make a selection of information when entering a record, with radio buttons giving the option of yes, or no. Which stores their answer as yes, or no in the database. I then have an...
6
4064
by: TheKeith | last post by:
I am doing a form for my site and would like to enable and disable a radio button set depending on whether one of the choices on an outer radio button set is checked. How can I refer to all the...
4
3251
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
3
2336
by: ewitkop90 | last post by:
Here is my code: <SCRIPT> function transportchange(transport) { if (framenewinstall.Helpdesk.checked) framenewinstall.Helpdesk.checked=false; if (framenewinstall.CircuitNumber.checked)...
1
3364
by: MickG | last post by:
I am trying to change the value of the variable "hard" according to which radio button is pressed and I am having no joy. Could anyone help me with this, the problematic section is marked with...
4
3228
by: Jay | last post by:
I have a form used to submit data (no surprises there!). I'd like to be able to populate the same form with previously submitted data. The data lives in a database once submitted and using ASP I...
4
2831
by: TS | last post by:
My objective: To create a survey that asks people to rate a list of things in order of importance. I wish to prevent them from just rating every item in the list the same value. For example the...
11
3112
by: saurabh | last post by:
Can anybody tell me how to change the value of an html control from the c#.... eg i hv one asp.net radio button control and one html hidden variable... so on page load in case the radio button is...
3
1283
by: tragic54 | last post by:
Alright so i've come across a problem. Basically what i have is 3 seperate radio buttons within a panel labeled ( tall, huge, bucket) I'm trying to return values from check boxes once the choice of...
0
7229
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7129
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7333
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.