/    Sign up×
Community /Pin to ProfileBookmark

Appending form field data to url and posting

I created an html email newsletter for a company that sells events tickets online. In the html email there is a “Search Events” text input field and a “GO” button to submit the search to find available tickets on their website.

The client provided me with a url similar to the one that follows: [url]http://www.domainaname.com/ResultsGeneral.aspx?kwds=[/url]

I need to create a form that that allows the user to enter a search term like Celine Dion in the text field and have it automatically append it after the = at the end of the URL like in this example:

[url]http://www.domainaname.com/ResultsGeneral.aspx?kwds=Celine_Dion

Hitting the GO (submit) button would take them to the site and return the results for the searched keyword(s).

Could someone tell me how I might accomplish this as easily as possible?

Thanks.

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@atuchJul 07.2008 — Use a form with the GET method and name the input box "kwds"
Copy linkTweet thisAlerts:
@meskeyauthorJul 07.2008 — Thanks so much. Works like a charm! ?
Copy linkTweet thisAlerts:
@nranaJul 24.2008 — i also need this one.. could you please post the code how did you do this? i tried doing it.. but could get through...
Copy linkTweet thisAlerts:
@nranaJul 24.2008 — can't i do it using DHTML and Javascript. cant use asp/php ?

<a href="www.hotmail.com" id="hotmail">click here </a>

<input name="Test" value="Hello" type="text" />

<script type="text/javascript">

window.location.href = document.getElementById('hotmail').href; </script>


Now i need to add that "hello" behind that URL ?
Copy linkTweet thisAlerts:
@ask21900Jul 24.2008 — newurl = window.location.href + "?hotmail=" + document.getElementById('hotmail').value;

Or maybe I don't understand what you are asking for?
Copy linkTweet thisAlerts:
@nranaJul 24.2008 — i need to append the value from the text box to the URL.

something like this:

text box = <input name="Test" value="Hello" type="text" />

Kind of like Grabbing teh Value from Text box and adding behind the URL.. sorry if this is really confusing..

http://www.domainname.com/Test=Hello
Copy linkTweet thisAlerts:
@ask21900Jul 24.2008 — yeah... did you try my suggestion?
Copy linkTweet thisAlerts:
@meskeyauthorJul 24.2008 — See if this works....


<FORM name="putformnamehere" method="get" action="http://www.yoururl.com/test=">

<TABLE BORDER="0">

<!--DWLayoutTable-->

<TR>

<TD><input type='text' name='test' value='DEFAULT TEXT' size='17' maxlength="40" /></TD>

<TD>&nbsp;<input type="image" name="GO" src="imagelocationhere" width="40" height="22" /></TD>

</TR>

</TABLE>

</FORM>
Copy linkTweet thisAlerts:
@nranaJul 24.2008 — ask21900,

no it didn't work. its not grabbing the value from text box.
Copy linkTweet thisAlerts:
@ask21900Jul 24.2008 — Try encapsulating the js in a function to be called onkeyup:

<script type="text/javascript">

function updatehref(linkvalue){

document.getElementById('linkdiv').innerHTML = '<a href="link.php?link=" + document.getElementById(linkvalue).value

}

</script>

<input name="Test" value="Hello" type="text" onkeyup="updatehref(this.value)"/>

<div id="linkdiv">The link will be written here when a value is typed in the text box.</div
Copy linkTweet thisAlerts:
@nranaJul 24.2008 — i figured it out.. this worked: Thanks for your suggestions...

<input name="test" id="test" value="Hello" type="hidden" />

<script type="text/javascript">

window.location.href="http://www.domain.com/?value=" + document.getElementById('test').value;

</script>
×

Success!

Help @meskey 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.27,
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,
)...