unistake Posted August 6, 2009 Share Posted August 6, 2009 Hi all, got a simple problem for you I am trying to create an outcome by clicking on radio buttons, I cant seem to get the 'document.write' to work and display the text at the bottom of the radio buttons, with those radio buttons still showing. The code I have is: <html> <head> <script type="text/javascript"> function calc (){ selection = document.getElementsByName("typeofbet"); for(i=0; i<selection.length; i++){ if(selection[i].checked == true){ var selected = selection[i].value; } } if(selected == "qualifier"){ qualifier(); }else{ if(selected == "freesr"){ sr(); }else{ if(selected == "freesnr"){ snr(); } } } } function qualifier (){ document.write('this is the qualifier!'); } function sr(){ document.write('this is the sr!'); } function snr(){ document.write('this is the snr!'); } </script> </head> <body> <form name="calcform"> <p> <input type="radio" name="typeofbet" value="qualifier" onClick="return calc();"> qual <input type="radio" name="typeofbet" value="freesr" onClick="return calc();"> sn <input type="radio" name="typeofbet" value="freesnr" onClick="return calc();"> snr </p> </form> </body> </html> Thanks for the heads up Quote Link to comment Share on other sites More sharing options...
alex3 Posted August 6, 2009 Share Posted August 6, 2009 Your document write function is writing to the head section of the document. This will probably make most browsers freak out a little as they weren't expecting any text to appear there. Quote Link to comment Share on other sites More sharing options...
unistake Posted August 6, 2009 Author Share Posted August 6, 2009 Thanks for the reply, can you tell me how to stop it going to the head of the page? Quote Link to comment Share on other sites More sharing options...
Maq Posted August 6, 2009 Share Posted August 6, 2009 Please don't double post. It wastes peoples' time. Quote Link to comment Share on other sites More sharing options...
unistake Posted August 6, 2009 Author Share Posted August 6, 2009 i put it on the wrong thread, so i re-posted and it was moved! wont happen again Quote Link to comment Share on other sites More sharing options...
Maq Posted August 6, 2009 Share Posted August 6, 2009 i put it on the wrong thread, so i re-posted and it was moved! wont happen again Gotcha. If you post in the wrong forum you can click on "Report to a Moderator" and it should be moved in a couple of moments. Quote Link to comment Share on other sites More sharing options...
unistake Posted August 6, 2009 Author Share Posted August 6, 2009 ok cheers, do you have an answer to my other post ive just put on ? cheers 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.