onChange Textbox Equal to Forms Action

Discussion in 'JavaScript' started by !Unreal, Jan 30, 2009.

  1. #1
    <form action="search.php?q=VALUE" type="post" />
    <input type="text" id="textbox" name="poster" size="25" />
    <input type="submit" class="button" value="Go" />
    </form>
    HTML:
    I have this form....What I want is for where it says VALUE to change in the forms action to be the same as what is in the textbox.

    I cant find anything on the internet that will do this seemlessly without the user noticing.

    By the way Im a complete javascript newbie, so treat me gently :p
     
    !Unreal, Jan 30, 2009 IP
  2. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You don't need to do it, if you're doing a POST. The value of the textbox (poster) will be made availabe in the POST variables.
     
    GreatMetro, Jan 30, 2009 IP
  3. !Unreal

    !Unreal Well-Known Member

    Messages:
    1,671
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    165
    #3
    I know but I have some slightly unusual circumstances.
     
    !Unreal, Jan 30, 2009 IP
  4. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <script type="text/javascript">
    function UpdateAction(val) {
        document.getElementById("myForm").action = "search.php?q=" + val;
    }
    </script>
    
    <form action="search.php?q=VALUE" id="myForm" type="post" />
    <input type="text" id="textbox" name="poster" onchange="UpdateAction(this.value);" size="25" />
    <input type="submit" class="button" value="Go" />
    </form>
    
    Code (markup):
     
    zerxer, Jan 31, 2009 IP