0

I have a onclick event which is designed to launch a javascript function getDeadlineInfo

function getDeadlineInfo(string)          //string holds name of deadline
{
    document.location.href='deadlineInfo.htm';
}

It is meant to open a new page "deadlineInfo.htm". I need that new page to display content from the server which I have my own function for:

function contactServer(str)                  
{
    ...additional code here
    xmlhttp.open("GET","serverScript.php?q="+str,true);
    xmlhttp.send();
}

The problem is I have no idea how to send the string variable which is passed into getDeadlineInfo to str which is used to look up the sql database. I have been googling around and most methods I've seen include using something along the lines of http://www.tek-tips.com/faqs.cfm?fid=5442, which doesn't work for me if I append the format like document.location.href="deadlineInfo.htm?name="+string;

Thanks for any help!

user1152440
  • 895
  • 2
  • 13
  • 25

2 Answers2

0

If you want to pass along information between full page refreshes you can either do that via the server (by submitting the value and placing it in the response html again (eg var str = "", or you can use some sort of client side storing, like cookies.

Koen Peters
  • 12,798
  • 6
  • 36
  • 59
0

A couple suggestions.

  1. Encode the url parameter using encodeURIComponent -> document.location.href="deadlineInfo.htm?name="+encodeURIComponent(string);
  2. Change "deadlineInfo.htm" to a php page -> "deadlineInfo.php" and process the name parameter on the server using the $_GET collection
  3. If you cannot change the page to a php page, use JavaScript to get the name function from your query string.
Community
  • 1
  • 1
dana
  • 17,267
  • 6
  • 64
  • 88