I have done a good amount of searching on how to pass data from a webpage to javascript but I have not found a solution to passing a string. And that is exactly what I am trying to do, simply pass a string to a java script function. The following is my code:
<a href = "website.html?gender='boy'">
<IMG STYLE="position:absolute; TOP:250px; LEFT:100px; WIDTH:300px; HEIGHT:300px" SRC="images/boy0023.png"/>
</a>
<a href = "website.html?gender='girl'">
<IMG STYLE="position:absolute; TOP:250px; LEFT:600px; WIDTH:300px; HEIGHT:300px" SRC="images/girl0023.png"/>
</a>
I have tried various ways to try and get this working including: removing the '' around boy and girl, using a button rather than a sprite, using "" around boy and girl. So on click, I am redirected to the page and I create a global variable named gender to hold the information then try to use gender in my funciton as so:
var gender // Creates the global gender variable
init(gender){
//code goes here
}
So I am not getting the results that I want on the page and when I go into console and type in gender; I receive the message that gender is undefined. So my question is, what am I not understanding here and what am I doing wrong?