One small help in javascript

Discussion in 'JavaScript' started by chanakya, Jul 23, 2008.

  1. #1
    I have a form

    <form action="search1.php" method="post" name="q">
    <table align="center"><tr><td>Search for <strong>RINGTONES</strong>:</td><td>
    <input name="artist" type="text" value="Search i.e Rihanna" size="10" maxlength="100" onclick="if(this.value=='Search i.e Rihanna') this.value='';" class="input" style="width:185px; background-color:#fae9f2; border: solid #ffcce7 1px; font-size: 12pt;"></td><td>
    <input type="submit" name="search" id="search2" value='Search!'>
    </td></tr></table>
    </form>

    Now , i want to change form action page while submitting as

    <form action="search1.php?keywords=<some value>" method="post" name="q">

    where <some value> is input value of field artist from the form

    can anyone help me to sort it out ?

    Thanks in advance
     
    chanakya, Jul 23, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    You don't need Javascript for that. You can do that with pure HTML:
    
    <form action="search1.php" method="get" name="q">
    <!-- .... -->
    <input name="keywords" type="text" .... />
    
    HTML:
    (Note the method = GET, and the field name = keywords.
     
    nico_swd, Jul 23, 2008 IP
  3. chanakya

    chanakya Peon

    Messages:
    361
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No , My question was not the method of getting values on next page, I want to change url structure of next page based on user input,

    That means a user inputs test keyword in this form

    <form action="search.php" method="get" name="q">
    <!-- .... -->
    <input name="keywords" type="text" .... />

    My next page url should be search.php?keywords=test not search.php
     
    chanakya, Jul 23, 2008 IP
  4. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    rofl.

    You only need to do what you do if you want to send post & dynamic get variables, otherwise just use nico's code and it will work,
     
    MMJ, Jul 23, 2008 IP
  5. thatonealex

    thatonealex Member

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #5
    chanakya check your PM..

    Come on MSN and ill help you out.
     
    thatonealex, Jul 23, 2008 IP
  6. chanakya

    chanakya Peon

    Messages:
    361
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Lolz, Am i too complicated in my question.

    I do not want to post values , I want to change action url structure on submit button
     
    chanakya, Jul 23, 2008 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #7
    That's what my frikkin code does... Try it and you'll see.
     
    nico_swd, Jul 23, 2008 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    No, but too lazy to even try the code people provide you.
     
    nico_swd, Jul 23, 2008 IP
  9. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #9
    wow, what a failure.
     
    MMJ, Jul 24, 2008 IP
  10. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #10
    Yep, I bet he feels intelligent now...
     
    nico_swd, Jul 25, 2008 IP