Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    71
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Changing form action with jquery

    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?

  • #2
    New Coder
    Join Date
    Nov 2006
    Posts
    71
    Thanks
    12
    Thanked 0 Times in 0 Posts
    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);
    });





    });


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •