...

View Full Version : Building Hyperlinks from Form Field Entry



kinron
03-30-2011, 06:05 AM
I need to create a page where a user enters text into a form field like campaign_id and selects "Generate". Once doing so, a series of hyperlinks on the page would be appended as follows: http://www.domain.com?campaign_id=value

Can anyone provide assistance or point me in the direction of a resource?

oVTech
03-30-2011, 06:55 PM
I need to create a page where a user enters text into a form field like campaign_id and selects "Generate". Once doing so, a series of hyperlinks on the page would be appended as follows: http://www.domain.com?campaign_id=value

Can anyone provide assistance or point me in the direction of a resource?


Check out these links:
http://www.codingforums.com/archive/index.php/t-74664.html
http://www.codingforums.com/archive/index.php/t-179100.html
http://www.webmasterworld.com/forum91/4044.htm
http://www.dynamicdrive.com/forums/showthread.php?t=49108

(http://stackoverflow.com/questions/4006991/build-url-from-form-fields-with-javascript-or-jquery)

Good luck!

djh101
03-30-2011, 07:09 PM
http://www.tizag.com/javascriptT/
If you don't require any server side assistance, Javascript could do this very easily. Something like this:


<form>
<fieldset>
<label for="textin">Text:</label><input type="text" id="textin" name="textin" />
<input type="button" onclick="document.getElementById('url').innerHTML=document.getElementById('textin').value" />
</fieldset>
</form>

<textarea rows="1" cols="20" id="url"></textarea>


That's the basic idea. Your button activates a string of Javascript code. document.getElementById is used to get an element by its ID, in this case, the id is 'url'. innerHTML refers to the HTML code between the opening and closing tags of that element. value refers to the attribute 'value' which will be the text entered into the input box 'textin'. This function sets the inner HTML of 'url' to the value of 'textin'. A little more code might be necessary if you want to append the value of textin to a preset URL, but a quick readthrough of a Javascript tutorial and you should have no problem doing that yourself.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum