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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Javascript function return value ... how to use that

    Hai...

    I created one drop down list box with enable and disable options. if enable is selected and click submit then it has to display 'changed from disabled', for this I wrote one javascript function with this, if I want to display the value on the text box then it is working fine. But I am not able to display the same value in the table. I am send the sample code here...


    plz see below commented code is to display the value in the text box. Now I am tring with the table option. I have to display these values in the table anyhow. Any one plz help me. I stuck here...

    <html>
    <head>
    <title> example</title>
    <script type="text/javascript">
    function moveNumbers()
    {
    var no=document.getElementById("no")
    var option=no.options[no.selectedIndex].text
    var txt=document.getElementById("result").value
    if (option =="Enable")
    var tt="Changed from Disable"
    else
    tt="Changed from Enable"

    document.getElementById("result").value=tt
    }
    </script>
    </head>
    <body>

    <form>
    <table border=2>
    <caption>Configuration</caption>
    <tr>
    <td> <select id="no">
    <option>Enable</option>
    <option>Disable</option>
    </select>
    </td>
    <td id="result"> </td>
    </tr>
    </table>
    <br>
    <input type="button" onclick="moveNumbers()" value="Submit">
    <!--<input type="text" id="result" size="20"> <!--commented code-->
    <table border=2>
    <tr><th id="result">hai</th>
    <td>hello</td>
    </tr>
    </table> -->
    </form>

  • #2
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    Try .innerText instead of .value.


  •  

    Posting Permissions

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