Jump to content

Recommended Posts

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 ;)

 

Link to comment
https://forums.phpfreaks.com/topic/169140-solved-simple-documentwrite-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.