mtgriffiths Posted April 13, 2008 Share Posted April 13, 2008 Hey All, What i am trying to do is capture the value of a text box. I cannot do the submit to self as it is inside of a form. I have 2 buttons on my page. The text box is used inside one form but i need to be able to access the value inside the form incase the user presses the other button. I'll try to explain a little better.... I have a search page that brings up results in a table. There is a quantity text box that allows the user to enter how many of the searched item they would like. There is a button to add to cart and another button to take the values to a different page. The quantity is currently linked to the cart button but i need to capture the value incase they press the other button. Is this possible...if so could anyone help? Thanks in advance Matthew Link to comment https://forums.phpfreaks.com/topic/100893-capturing-value-of-a-text-box/ Share on other sites More sharing options...
Barand Posted April 13, 2008 Share Posted April 13, 2008 <?php if (isset($_POST['btnSubmit'])) { $qty = $_POST['qty']; switch ($_POST['btnSubmit']) { case 'Search': // do search echo "searching"; break; case 'Next page': // go to other page echo "redirecting"; break; } } ?> <form method='post'> Quantity : <input type="text" name="qty" size="5" /><br /> <input type="submit" name="btnSubmit" value="Search" /> <input type="submit" name="btnSubmit" value="Next page" /> </form> Link to comment https://forums.phpfreaks.com/topic/100893-capturing-value-of-a-text-box/#findComment-515968 Share on other sites More sharing options...
mtgriffiths Posted April 13, 2008 Author Share Posted April 13, 2008 Thank you for your reply. I am looking at the code and i am a little confused. I have information from an array that is being posted over also with the button press...would i have to include that as a post variable aswel? Thanks again Link to comment https://forums.phpfreaks.com/topic/100893-capturing-value-of-a-text-box/#findComment-515971 Share on other sites More sharing options...
mtgriffiths Posted April 13, 2008 Author Share Posted April 13, 2008 I have been looking around but dont know if this is possible... I know that it is possible to get the value of a text box using this javascript code: document.formname.textboxname.value Is there anyway to take the result from this and change it into a variable that i can use? Link to comment https://forums.phpfreaks.com/topic/100893-capturing-value-of-a-text-box/#findComment-515989 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.