jmfekete Posted September 18, 2006 Share Posted September 18, 2006 Hi,My index page has two text fields where they input what they want to do a search on and in what city, and then hit submit. I am then supposed to pass those 2 parameters into the form's "action". For example:<form name="search" method="post" action="http://blahblah/blah.aspx?zipcode=PARAMETER1&item=PARAMETER2" id="search"> <table width="60%" border="0" align="center" name="tblInfo"> <tr> <td width="30%"><input name="whatTxt" type="text" id="whatTxt" onKeyDown="(search,event)"></td> <td width="33%"><input name="locationTxt" type="text" id="locationTxt" onKeyDown="(search,event)"></td> <td width="37%"><input name="Search" type="submit" id="Search" value="Search"></td> </tr> <tr> <td>What are you looking for?</td> <td>Where are you looking for it?</td> <td></td> </tr> </table></form>How can I set PARAMETER1 and PARAMETER2 to the text entered by the user once they click on "Search"?I thought that if I put the field's ID name in place of PARAMETER1 and PARAMETER2 in the action URL that it might pass them through, but I was sadly mistaken.Thanks to anyone who can shed some light! Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 just set the forms method="get" and it is done automatically. Link to comment Share on other sites More sharing options...
jmfekete Posted September 18, 2006 Author Share Posted September 18, 2006 just set the forms method="get" and it is done automatically.Hi,Thanks for the quick response. I need to use the post method because my index page (which is local on my machine) interfaces with an ASPX page which is sitting on a server when the search is submitted. So I need to pass those parameters into the "Action" URL somehow, but I am not quite sure how.Any ideas?Thanks again! Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 you would have to use javascript for that, but then you will have the same 2 fields passed as post and get...is this what you are going for? Link to comment Share on other sites More sharing options...
jmfekete Posted September 18, 2006 Author Share Posted September 18, 2006 you would have to use javascript for that, but then you will have the same 2 fields passed as post and get...is this what you are going for?Well, because this project serves as a "search" function, I only want to use post. I have a login/password to access the server's URL where the ASPX page resides (which is added to the form's action), but I cannot seem to pass those 2 parameters that the user inputs along to the ASPX so that the search can begin.I hope that made sense. Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 you could do something like this <html><head> <title>GET example</title> <script type="text/javascript"> function sendSearch() { var param1 = document.getElementById('param1'); var param2 = document.getElementById('param2'); var theForm = document.forms[0]; theForm.action += "?param1=" + param1.value + "¶m2=" + param2.value; theForm.submit(); } </script></head><body> <form action="search.aspx" method="post"> Param 1: <input type="text" id="param1" name="param1"/> <br/> Param 2: <input type="text" id="param2" name="param2"/> <br/> <input type="button" value="Search" onclick="sendSearch()"/> </form></body></html> Link to comment Share on other sites More sharing options...
jmfekete Posted September 18, 2006 Author Share Posted September 18, 2006 OMG!!! You ARE the best!!!Thank you so much for all your help! Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 OMG!!! You ARE the best!!!Thank you so much for all your help!glad it works, your very welcome Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now