blackcode has asked for the wisdom of the Perl Monks concerning the following question:

Greetings everyone I have 1 textbox and 2 buttons (BUTTON-A and BUTTON-B). I would like to when a user types "hEy buddy" in textbox and (hit enter or press BUTTON-A) - to go to - site.com/index.php?=hEy buddy&more ( and if without hitting enter and pressed BUTTON-B using mouse ) Then go to site2.com/page.php?=hello&more I would really appreciate any help! :) Regards John
  • Comment on how can i take value in TextBox and pass to a URL?

Replies are listed 'Best First'.
Re: how can i take value in TextBox and pass to a URL?
by marto (Cardinal) on Dec 10, 2009 at 09:47 UTC
Re: how can i take value in TextBox and pass to a URL?
by Anonymous Monk on Dec 10, 2009 at 08:45 UTC
Re: how can i take value in TextBox and pass to a URL?
by Anonymous Monk on Dec 10, 2009 at 14:22 UTC
    Javascript seems to be the answer. Frankly I cannot see how perl or cgi will help here...
Re: how can i take value in TextBox and pass to a URL?
by scorpio17 (Canon) on Dec 10, 2009 at 14:51 UTC

    Something like this, maybe?

    <html> <body> <form method="get" action="http://site.com/index.php"> <input type="text" name=""><br> <input type="hidden" name="more" value="whatever"> <input type="submit" value="Button-A"> </form> <br> <form method="get" action="http://site2.com/page.php"> <input type="hidden" name="" value="hello"> <input type="hidden" name="more" value="whatever"> <input type="submit" value="Button-B"> </form> </body> </html>

    Note that using name="" is considered bad form, but if you change it to something like name="mytext" the URL you request will change to:
    "http://site.com/index.php?mytext=heybuddy?more=whatever"

      Hi <form method="get" action="http://site.com/index.php"> <input type="text" name="">
      <input type="hidden" name="more" value="whatever"> <input type="submit" value="Button-A"> ^ this part works fine, But the second form cannot take values from the textbox of the first form is the problem :(

        You want the value in the text box transmitted when EITHER button is clicked, not just the first? I guess I misunderstood the problem.

        Here's another trick you can use: just have one form, but use two submit buttons:

        <input type="submit" name="submit" value="ButtonA"><br> <input type="submit" name="submit" value="ButtonB"><br>

        Then your CGI script can check the value of the submit button, and branch accordingly. In your case, I suppose you'd simply do a redirect to the URL you want.

        And, yes, I currently am using Javascript for this purpose. But the reason i am reluctant to go ahead with Java is since Java is depends on if its installed or not. That's why i thought using PERL/CGI may solve the problem. Regards John