Jump to content

document.write in form


dreamwest

Recommended Posts

Radio buttons don't automatically output the value of the value attribute. Try it this way:

 

<form method="post" action="">
<label>
	<script type="text/javascript">
		document.write("Potatos");
	</script>
</label>
<input type="radio" id="" value="<script type='text/javascript'>document.write('Potatos');</script>" />
  </form>
[code]

If you just wanna change the value of your radio button:

 

var radioBtn = document.getElementById('country');
radioBtn.value = "Your desired value";

 

If you wished to change your label as well, make sure your label did set the for to the radio button's ID:

<label for="country">Your Label</label>

 

in your script:

var labels = document.getElementsByTagName('label');
for(var i=0,len=labels.length; i<len; i++) {
    var lbl = labels[i];

    if(lbl.for == 'country') {
        lbl.innerHTML = 'Your desired label value.';
    }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.