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.

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,136
  • 2
  • 35
  • 58
0

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

SRing
  • 696
  • 6
  • 15
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,069
  • 1
  • 21
  • 32