dreamwest Posted July 18, 2009 Share Posted July 18, 2009 how can i add document.write to a radio button value?? <input id="country" name="meta" value="<script>document.write(geoip_country_code());</script>" type="radio"> Quote Link to comment Share on other sites More sharing options...
chordsoflife Posted July 18, 2009 Share Posted July 18, 2009 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] Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 18, 2009 Share Posted July 18, 2009 don't you want to use html entities? Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted July 18, 2009 Share Posted July 18, 2009 how can i add document.write to a radio button value?? <input id="country" name="meta" value="<script>document.write(geoip_country_code());</script>" type="radio"> What are you trying to accomplish with this? Quote Link to comment Share on other sites More sharing options...
xenophobia Posted July 18, 2009 Share Posted July 18, 2009 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.'; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.