How to pass parameters between pages/forms in HTML?


I am new to HTML.
I have a page, on this page I have a form with button. when I click the button another form opens (from another page). I need to pass a parameter to this form when it opens. Is it possible?
If yes, how to do it?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

erikTsomikSystem Architect, CF programmer Commented:
yes you can pass the parameters by using as cgi variables, form variables and so on
take a look at this post
erikTsomikSystem Architect, CF programmer Commented:
Shaun KlineLead Software EngineerCommented:
There are a number of ways. One would be to have a hidden field (input type="hidden") and put your parameter into this field. A second way would be to alter the action property of the form tag to include the parameter as part of the query string (<page>?<parameter key word>=<parameter value>.

If you need to determine what that parameter value should be based on what the user entered, then you are looking at using javascript to handle setting the hidden field value/changing the action property.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Yours source form has to use "GET" method

<form name='yourSrcForm' method='get' action='dest.html'>
<input type='text' name='testSrc' value='Hello'>

So, in your destiny html you have to use some javascript to read the params passed and set the params to your new form. Something like this:

<form name='yourFinalForm'>
<input type='text' name='testDest'>
<script language='javascript'>
// Getting all params passed and storing in qsParm array
var qsParm = new Array();
var query =;
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
   var pos = parms[i].indexOf('=');
   if (pos > 0) {
       var key = parms[i].substring(0,pos);
       var val = parms[i].substring(pos+1);
       qsParm[key] = val;
// Set the value to new form
document.yourFinalForm.testDest.value = qsParm['testSrc'];

Open in new window


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
to make this simple do the following:

<form name="input" action="second_page.html" method="get">
<input type="text" name="user" />
<input type="submit" value="Submit" />

so the second_page will open in browser as:

so there you go, you have passed a parameter value to next page.

However, the easiest way to get this parameter to page content is for example with php:
1. rename second_page.html to second_page.php
2. in second_page.php file type: <?php echo "I typed:" . $_request['user']; ?>

You can ofcourse use other methods (with aspx, jsp, js,....)

If you`re new to html then I suppose you haven`t tried any server side lang. either.
Just to get you started:
- install wamp server :
- rename all *.html files to *.php
- copy *.php files to wamp www destination
- in browser type http://localhost/first_file.html

in browser type http://localhost/first_file.php

  It isn't php language, it's pure HTML. Just renaming files may not work if the server was not correctly configured.
margaritAuthor Commented:
Thanks for so many helpful comments.
I am already using Java script.
My page2 should get a parameter from page1 but later it should pass back to page1 a list of parameters. So what action should I set : "set" or "get"?
How to implement it?
The method to pass parameters from one simple HTML doc to another is always GET.

The "action" is the file that will receive the parameters.

So the page1.html, must has the form like this:

<form name='frm1'  action='page2.html' method='get'>

And page2 like this:

<form name='frm2'  action='page1.html' method='get'>
margaritAuthor Commented:
I will try it now
margaritAuthor Commented:
I tried the xBellox solution, but the problem that in my DestPage I get nothing. If I print "query"  it is empty. Why?
margaritAuthor Commented:
Hi, At first I had a problem but then I defined a button as "submit " and it works.
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

From novice to tech pro — start learning today.