0

I have a site where I enter an input it brings up a page specific to my input;

The URL is something like this; https://hum.drum.something.com/cgi-bin/nhc.pl

What I'd like to do is send out links like this https://hum.drum.something.com/cgi-bin/nhc.pl?MAN_search=4AA11 with 4AA11 being the value or id="myName" I would enter on the site.

  • 1
    So what exactly is your question? Look into PHP get variables. – Spencer May Feb 10 '15 at 19:22
  • @SpencerMay, You can't say, "Look into PHP..." when we don't even know what tech the OP is using... (It looks like perl, by the way.) – ps2goat Feb 10 '15 at 19:25
  • I think this will help http://stackoverflow.com/questions/5448545/how-to-retrieve-get-parameters-from-javascript – JJJ Feb 10 '15 at 19:26

3 Answers3

1

Make a similar form:

<form action="nhc.pl" method="get">
    <input type="text" name="MAN_search" />
    <input type="submit"/>
</form>

This will submit the appropriate GET request to your web server.

meskobalazs
  • 15,741
  • 2
  • 40
  • 63
0

Use document.URL to get the current URL and examine the last X characters as you need.

SRing
  • 694
  • 6
  • 16
0

This is a question that is asked many times, and could also be answered by searching Google for two minutes.

However, I'll try to give you a short answer. Getting variables from the URL is much easier using php. All you need to do to access the value of the variable is:

$_GET["MAN_Search"]

If you want to achieve the same using only JavaScript, the solution would look something like this:

    function getQueryVariable(variable) {
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
   }

If you would call getQueryVariable("MAN_Search"), the result would be 4AA11 (taking your example URL).

ksbg
  • 3,214
  • 1
  • 22
  • 35