passing the parent form on the onclick event to javascript function

Posted by user1051505 on Stack Overflow See other posts from Stack Overflow or by user1051505
Published on 2012-12-18T04:41:20Z Indexed on 2012/12/18 5:03 UTC
Read the original article Hit count: 171

Hi I am trying to pass variables on the onclick event to a javascript function. I am trying the following way, I can't get the input value in the javascript function.(I am expecting an alert of 1.) Is it the right way of doing this? Please help.

<head>
    <script>
        function submit_value(form) {
            alert(form.ip.value);
        }
    </script>
</head>
<table>
    <tr>
        <form>
            <td>
                <input id="ip" type="text" value="1">
            </td>
            <td>
                <a href="javascript:;" onClick="submit_value(this)">Button</a>
            </td>
        </form>
    </tr>
</table>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html