Radio Button Pre-selected By Variable Value

Discussion in 'HTML & Website Design' started by KaiSmith, Feb 15, 2013.

  1. #1
    Any help to make this work?
    <html>
     
    <head>
    <script>
    function radio(){
    var radiox=1;
    var postaja=document.formm.vrednost;
    for (var i=0; i<postaja.length; i++);
    if(radiox==1){
    postaja[i].checked =true;
    postaja[i].setSelection(true);
    }
    else postaja[i].checked =false;
    }
    </script>
    <title></title>
     
    </head>
     
    <body>
    <form name="formm">
    <input type="button" value="setvalues" onclick="radio()"><br>
    1<input type="radio" name="vrednost" value="radio1">
    2<input type="radio" name="vrednost" value="radio2">
    3<input type="radio" name="vrednost" value="radio3">
    </form>
    </body>
     
    </html>
    Code (markup):

     
    KaiSmith, Feb 15, 2013 IP
  2. cesurasean

    cesurasean Active Member

    Messages:
    269
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #2
    <input type=submit ?? Do you mean how do you make the form submit? What error, or problem are you having with your code? It looks fine to me, except if it's not using "submit" as a type for a button, or what not, then it's not going to actually make the browser submit anything, or process the form code.
     
    cesurasean, Feb 20, 2013 IP