/    Sign up×
Community /Pin to ProfileBookmark

inserting a variable in my form action

Hey all,

I’ve got this form.

<form name=”viewPage” method=”post” action=”index.html?var=_______”>
<input type=”hidden” name=”var”>
</form>

What I basicly want to do is display the variable “var” where there are some underscores. I have done this with PHP but since its server side it displays the value of the precedent submit. I want to somehow enter the var info with javascript?

Any idea on how to go about to do this?

Thanx,
Pat~

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@twindaggerNov 05.2004 — leniouf-

If you want to submit all form variables to the url, instead of just one, you can do this:

[code=php]
<form name="viewPage" method="get" action="index.html">
<input type="hidden" name="var">
</form>
[/code]


Instead of posting the information, the browser will append all of the form fields to the URL. If you want to only do this with one form field, but have the others go on as normal, you can do this:

[code=php]
<form name="viewPage" method="post" action="index.html" onsubmit="this.action += '?' + this.var.value">
<input type="hidden" name="var">
</form>
[/code]
×

Success!

Help @leniouf 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...