Forum Moderators: open

Message Too Old, No Replies

Query strings and forms

Can you pass a dynamic query string on a form action?

         

thrasher141

12:03 am on Nov 5, 2004 (gmt 0)

10+ Year Member



I've just stumbled across this little problem that is perplexing. The goal is to create a search form where the user enters a keyword and presses 'submit', then they are taken to "searchresults.asp?query=KeywordEntered", where KeywordEntered is of course the keyword that the user put in the form. Is this possible?

In the form action you can define a static query string ('action="searchresults.asp?query=widgets"') but is there a say to make the query variable be dynamic?

My thought was to have no action for the form and instead of a submit button just make a submit link which would use ASP to redirect to the searchresults page and append the keyword from the form. But the problem is that pressing enter on the form would no longer work, you'd have to click a link.

Any other ideas? Thanks!

mrobinson

3:37 pm on Nov 5, 2004 (gmt 0)

10+ Year Member



I have perhaps misunderstood your query and missed something obvious, but could you use the GET method with the form, rather than the POST method?

e.g.


<form action="searchresults.asp" method="get">
<input name="query" type="text" />
<input type="submit" value="Search" />
</form>

That way the form request would be passed on the querystring (which is what I think you are looking for).

Regards,
Mark

thrasher141

4:30 pm on Nov 5, 2004 (gmt 0)

10+ Year Member



No, you didn't misunderstand. I'm just very ignorant. I'm still learning...thanks for the help!