views:

53

answers:

3

I have this:

function OpenVote(id, stemme)  {
  var postThis = 'infoaboutvote.php?id='+id+'&stemme='+stemme;
}

and this:

<script type="text/javascript">
OpenVote(10, CripO);
</script>

Why have i done wrong? as you see i want 10 to be "id" and CripO to be "stemme"

+1  A: 

Shouldnt it be OpenVote(10, 'CripO'); -- I mean with 'Cripo' within quotes?

Mihir Mathuria
+1  A: 

What do you want the function to do? Using the var keyword here indicates that that variable should only exist inside the function. If you're trying to set the postThis variable outside the function, omit the var.

Matchu
+2  A: 

"CripO" looks like a string to mea -- which means it should probably be surrounded by quotes :

<script type="text/javascript">
  OpenVote(10, 'CripO');
</script>

Else, it might be a variable -- in which case you should ensure it is initialized before executing that portion of code.


Also, in your OpenVote function, you are assigning an URL to the postThis variable ; but this will not do anything else.

Especially, it will not send any kind of Ajax request : you need more code, if you want to send an Ajax request to that URL, and get a result.

Pascal MARTIN