Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2008
    Posts
    25
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Replaced radio buttons with custom script

    I have replaced normal radio buttons with this script:

    Code:
    <!--
    
    //script to change background-color of the selected
    //button and put the appropriate value in an input object
    function btnClick(btnNum){
    for (i=1;i<=4;i++){
    tempBtnVal=document.getElementById('btnVal')
    tempBtn=document.getElementById('btn'+i)
    tempBtn.style.backgroundColor=(i==btnNum?'#ff0000':'#ffffff')
    }
    tempBtnVal.value=btnNum
    }
    //-->
    Using this html:

    <div id="btn1" name="btn1" class="buttonDiv" onclick="btnClick('1')">Option 1</div>
    <div id="btn2" name="btn2" class="buttonDiv" value='2' onclick="btnClick('2')">Option 2</div>
    <div id="btn3" name="btn3" class="buttonDiv" value='3' onclick="btnClick('3')">Option 3</div>
    <div id="btn4" name="btn4" class="buttonDiv" value='4' onclick="btnClick('4')">Option 4</div>
    <input id="btnVal" name="btnVal" type="text" value="" />
    The code is not mine. I used to set the variable's value like this:

    <input type="radio" name="answer" value="$option1" <if condition="$option1 == $answer">checked="checked"</if> /> $option1
    <input type="radio" name="answer" value="$option2" <if condition="$option2 == $answer">checked="checked"</if> /> $option2...
    How can I set the variable's value now using the new script?
    Last edited by joshua7; 04-23-2008 at 02:23 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    value="$option1" , $answer
    is it PHP ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Apr 2008
    Posts
    25
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    is it PHP ?
    yes, it's PHP


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •