/    Sign up×
Community /Pin to ProfileBookmark

How to get value of drop down in another page

Hi,

I have a page where only a drop down menu with Country names is there…

When the user selects any one of the values it will redirect to another page.

In that page, the user has to fill a form with fields name, age and country.

But in the second page the country field has to be automatically filled since the user has selected it in the first page.

So Is there a way where I can get the value of a drop down menu (selected from first page) on the second page????

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@KorJan 27.2011 — Usually this kind of job is made on a server-side level, using a server-side language, on submitting data from a document to another. It is also possible to pass some data using the address bar, and a hash, and JavaScript to retrieve those data. But server-side solution is better. Does your server support PHP?
Copy linkTweet thisAlerts:
@ManasipradeepauthorJan 27.2011 — But here in the first page, I dont want a submit button... So only drop down menu would be there... So when the user selects any value it should redirect to second page and the selected drop down value should be available there also...

I know that the using query string we can pass the paramenters... but I guess thats the case of a form where there will be a submit button....
Copy linkTweet thisAlerts:
@tirnaJan 27.2011 — If you want to pass data from one html page to another without server side scripting, you can use cookies or append the data to a query string.

You could put an onchange event handler on the select in page 1 which appends the selected value to the url for page 2 and then use [CODE]window.location.href = url;[/CODE] to redirect to page 2. Page 2 then parses the query string to get the sent data.
Copy linkTweet thisAlerts:
@KorJan 27.2011 — 
I know that the using query string we can pass the paramenters... but I guess thats the case of a form where there will be a submit button....[/QUOTE]

Not necessarily. You may submit the data straight from the list box:
<i>
</i>&lt;select onchange="this.form.submit()"&gt;
Copy linkTweet thisAlerts:
@rnd_meJan 27.2011 — cookie are the easiest to code and don't litter on the url...
×

Success!

Help @Manasipradeep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...