It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

Set Radio Button Value to a Predefined Javascript Value?

Set Radio Button Value to a Predefined Javascript Value?

Postby jbj on Thu Mar 29, 2007 3:40 pm

Hi I have what seems like a simple question but it has baffled me for hours now. How do I set the value of an HTML radio button to a predefined javascript value? I am trying to get the value of radioButton to = the javascript variable named countryText which is defined earlier in the page.

The following does not work obviously:

<input name="radioButton" type="radio" class="box" value="javascript:countryText" checked="checked" "/>

Any advice? thanks.
jbj
 
Posts: 2
Joined: Thu Mar 29, 2007 3:39 pm

Postby mwa103 on Thu Mar 29, 2007 4:43 pm

Try replacing that line with:
Code: Select all
<script type='text/javascript'>
     document.write("<input name='radioButton' type='radio' class='box' value='" + countryText + "' checked='checked' />");
</script>


Don't have time to test it right now, but I think that should work. Hope this helps.

-Mike
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm


Who is online

Users browsing this forum: No registered users and 5 guests