简体   繁体   中英

How to access text field value on same page without using $_post?

I have one text field with search button.

I want to access that text field's value on button click.

I can't use $_post because i have also one submit button inside.

So how to get that textfield's value on search button click.

my below's entire form is based on that unique value which was entered in that textdield

    </head> 
    <script>
    var getData = function()
    {
        var value = $("#inputData").val();
        alert(value);
    }
    </script>
<body>
<form id="form1" name="form1" method="post" action="pag3.php">
<tr>
<td></td>
<td></td>
</tr>

//Other code for form which textfield should fill from data which match with
enterd value.

At end i have put submit button which will send data on next page form perform insertion

You can use jQuery as follow

Html

<input type="button" name="" id="inputData">
<button onclick="return getData()" >Get Data</button>

script

var getData = function()
{
    var value = $("#inputData").val();
    return false; 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM