View Full Version : Changing form action with jquery

10-20-2010, 07:59 PM
This is what I have currently, All I want to do is dynamically change the form action depending on what someone types into #inputProxy field. I am finding myself mixing a lot of Jquery and Javascript per se'. Is this a normal practice?


var proxy = $("#inputProxy").val();

var url = proxy + "http://url.com/search"; //default form action


$("#sourceCode").val("<div id='discowidget'>" +
"<form name='searchform' method='get' action=''>" +
"<br>" +
"<input type='text' id='box' name='keyword1' size='30' maxlength='75' value='Please enter your search term' accesskey='x'>" +
"<input type='submit' value='Search' accesskey='r' class='btn'><br/>" +
"<input type='radio' id='subjectId' name='stype' value='subject' />" +
"<label for='subjectId'>Subject Headings</label>" +
"<input type='radio' id='keywordId' name='stype' value='basic' checked />" +
"<label for='keywordId'>Keyword</label>" +
"<br/>" +
"</form>" +



<form name='searchform' method='get' action=''>
<input name="inputProxy">
<textarea name="sourceCode">Output text goes here</textarea>


Any ideas?

10-20-2010, 11:27 PM

This is what I did

var proxy = $("#inputProxy").val();
var url = proxy + "http://hellfire.com/search";
var code = "ACTION =\"" + url + "\"/>