0

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

3
  • Dupe: stackoverflow.com/questions/719880/… Commented Apr 6, 2009 at 0:11
  • If you actually read carefully its two different questions, I made this one after I realized I asked the wrong question first. Commented Apr 6, 2009 at 0:29
  • Ok, no problem - just looked quite similar :) Commented Apr 6, 2009 at 0:42

2 Answers 2

2

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...

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.