Below is my script that updates my characters position in my database:
<script language="javascript" type="text/javascript">
function positionUpdate(){
var word = document.getElementById('test').value;
var queryString = "?word=" + word;
ajaxRequest.open("GET", "new_position.php" + queryString, true);
ajaxRequest.send(null);
alert(queryString);
}
</script>
Next is the script that tells the above script to run but I need to send two variables across to it so it knows what to update.
<a onClick="positionUpdate();"><img src="images/transparent.gif" border="0" /></a>
The link above is used multiple times so I need to send the values with that and not put the variables in the script at the top otherwise they would always be the same.
As a note I am using the php GET function to retrieve the variables in position_update.php
Thanks, tanni
Try:
<script language="javascript" type="text/javascript">
function positionUpdate(var1, var2){
var word = document.getElementById('test').value;
var queryString = "?word=" + word + "&var1=" + var1 + "&var2=" + var2;
ajaxRequest.open("GET", "new_position.php" + queryString, true);
ajaxRequest.send(null);
alert(queryString);
}
</script>
and
<a onClick="positionUpdate('val1', 'val2');"><img src="images/transparent.gif" border="0" /></a>
Is that what you mean? It seems like a fairly basic question...
I don't understand your question.
Why don't you just pass the variables as function parameters to positionUpdate?
Maybe you could explain in a bit more detail what you are trying to accomplish.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.