Include javascript input element into form action post

Discussion in 'JavaScript' started by japmedia, Sep 25, 2008.

  1. #1
    Any help to let's me know how i can get the input text typed by user to include into the form post action?

    ex:
    
    <form method="post" action="images-XXXXXX.html">
        <input name="keyword" size="30">
        <input type="submit" class="button" value="Search">
    </form>
    Code (markup):
    I want to have XXXXXX replaced by the keyword element. So when user type apple it post to images-apple.html

    JAP
     
    japmedia, Sep 25, 2008 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I've not tested that, but it should work.. You must add a onsubmit event to the submit buttton. The code that should be executed onsubmit is something like that:
    document.forms[0].action = "images-"+document.forms[0].keyword.value+".html";
    Code (markup):
     
    xlcho, Sep 26, 2008 IP
  3. japmedia

    japmedia Well-Known Member

    Messages:
    174
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Thank xlcho,

    It's exactly what i was looking for.

    JAP
     
    japmedia, Sep 26, 2008 IP