Form Search Box Question

http://www.test.com/search/jrs.aspx?test=50&scr=1024x768&keyw=cars&url=This.com

The above url is an example... Lets say the above URL returns a form with seach box in it and search button.

How do I get that form to post to the above url with the above parameters?

I really never understood how form posting getting or whatever works, it was very confusing lol.

HepenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

callrsCommented:
http://www.mcfedries.com/JavaScript/boilerplate-images.asp     Passing Data to Another Page
http://www.irt.org/articles/js063/index.htm     Passing data from one form to another
http://webdevelopersjournal.com/articles/pass_values.html   How Do I use JavaScript to Pass Values from one Field, Frame or Window to Another?


When form is submitted via the submit button or hitting ENTER (if there's a submit button), the browser takes the form data, formats it automatically, and appends it to the url contained in the action attribute

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
callrsCommented:
Try this simple Google search demo. Select, copy, paste into notepad, save & open in browser:

<!-- Submit via link and submit button     -->
<form name="magic" target=_self method="GET" action="http://www.google.ca/search">
<input type=submit name="sendme" value="Google.ca">
<input type=text name=q size=31 maxlength=2048 value="key" title="Search">
</form>

<a href="#" onclick="document.magic.action='http://www.google.com/search';document.magic.submit(); return false;">
<B>Search Google.com</B></a>
HepenAuthor Commented:
How do I pass the existing parameters to the page that gets posted?

jrs.aspx?test=50&scr=1024x768&keyw=cars&url=This.com

Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

TedInAKCommented:
Here's a basic explanation:  when "jrs.aspx?test=50&scr=1024x768&keyw=cars&url=This.com" gets called, jrs.aspx will have statements in there that will do stuff based on the parameters, like maybe:

if test is greater or equal to 50, tell the user that they've reached their limit of tests, and since "scr" = 1024x768, show the test results in a page optimzed to that screen resolution.

You could also use javascript to parse the url and make choices based on that.  But javascript is client-side, whereas my prior example gets executed on the server and does it's parsing before the page actually makes it to the client.
HepenAuthor Commented:
TedInAK that I understand.

Lets say jrs.aspx has a form on it and I want to use the existing information from test, scr, keyw & url.  How can I use these existing parameters? In this case 508,1024x768, cars & this.com .. how can I save that to use it again on another form post
TedInAKCommented:
If by save you mean to populate the form fields with that data, best way would be to do it server-side using ASP.net's built-in tools.  Is that what you mean?
sankar_raviCommented:
Hi Hepen,

I got your question.
Hope following code should answer you.
<html>
<head>
      <title>Untitled</title>
<script>
var querystring="";
//This is to get the parameters supplied in the URL
function run(){
      var url=location.href;
      var urlparts="";
      if(url.indexOf("?")>-1){
            urlparts=url.split("?");
            querystring=urlparts[1];
      }      
}
//Composing the URL to do the form submit
function formPost(){
      document.frm.action="<<actual URL(may be self url)>>"+querystring;
      document.frm.submit();
}
</script>
</head>
<body onload="run();">
<form name="frm" method="post">
<input type="text" name="searchstr" value="form post"><br>
<input type="button" value="Search" onclick="formPost();">
</form>
</body>
</html>

What actually I am doing here is that reading the above parameters in URL and saving them in a variable.
When I am clicking on the search button to do post, I am composing the action of the Form to append with above parameters.
Hope this point should be clear to you.

Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.