...

View Full Version : Changing form action with jquery



pcproff
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?

<script>
$("document").ready(function(){

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

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

$("#button").click(function(){

$("#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>" +
"</div>");

});
});

</script>

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


</form>

Any ideas?

pcproff
10-20-2010, 11:27 PM
Update**

This is what I did


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




$("#sourceCode").val(code);
});





});



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum