Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
113
rated 0 times [  120] [ 7]  / answers: 1 / hits: 85264  / 15 Years ago, sun, december 20, 2009, 12:00:00

I am trying to pass 2 values to a javascript xmlHttp request. The values are being passed to the javascript function. I was successfully passing a single value to the javscript function, but now I need to pass 2 values. The bold value is a string name I want in the javascript.


 echo "<a href='#' class='thumb'><img class='thumb-img' value = ".$row->aid." onclick='getVote(".$row->aid.", **".$row->atitle."**)' src='images/roadies/th".$row->aid.".jpg' />    </a>";

One is an int and the other is a string.


In the javascript, I am not sure how to receive these values. Earlier I used to do this:


function getVote(int)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
value = int;

for a single value. But now since there are 2 values to process, I don't know how to write the function for it.
I am currently (unsuccessfully) trying this:


function getVote(int, name)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
value = int;
name= char;

Please tell me how to do it?


More From » javascript

 Answers
3

You probably want to enclose the title in quotes. Let's say you have a row with aid 123 and title Hello World. You want to have onclick=getVote(123,'Hello World')


[#98027] Thursday, December 17, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myrap

Total Points: 407
Total Questions: 105
Total Answers: 109

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
;