davehaz
05-31-2006, 03:48 AM
howdy,
I have written a very basic script trying to figure out how to pass variables
function sendto(a)
{
alert(a);
}
I am using data originating from a php script, I am calling the function like below
$max = mysql_result( mysql_query("SELECT COUNT(*) FROM coupons WHERE merchant_dotcom LIKE ('$value%') "), 0 ) ;
if($max > '1'){$z = "Coupons";} else {$z = "Coupon";}
echo "<tr><td><a href='$url' onClick='sendto($max)'>$value</a>-$max $z available</td><td>$merchant_desc</td></tr>";
there is of course much more to the php script but the code above will work for my problem. When I call the function using $max a numeric variable such as
echo "<tr><td><a href='$url' onClick='sendto($max)'>$value</a>-$max $z available</td><td>$merchant_desc</td></tr>";
I get an alert box with the value of $max in it. However if I replace $max with any of the variables that are strings such as $z which would be Coupon or Coupons I get nothing, no alert box, nothing.
what am I doing wrong here? In javascript is there a way to differentiate between numeric and string variables?
thanks.
I have written a very basic script trying to figure out how to pass variables
function sendto(a)
{
alert(a);
}
I am using data originating from a php script, I am calling the function like below
$max = mysql_result( mysql_query("SELECT COUNT(*) FROM coupons WHERE merchant_dotcom LIKE ('$value%') "), 0 ) ;
if($max > '1'){$z = "Coupons";} else {$z = "Coupon";}
echo "<tr><td><a href='$url' onClick='sendto($max)'>$value</a>-$max $z available</td><td>$merchant_desc</td></tr>";
there is of course much more to the php script but the code above will work for my problem. When I call the function using $max a numeric variable such as
echo "<tr><td><a href='$url' onClick='sendto($max)'>$value</a>-$max $z available</td><td>$merchant_desc</td></tr>";
I get an alert box with the value of $max in it. However if I replace $max with any of the variables that are strings such as $z which would be Coupon or Coupons I get nothing, no alert box, nothing.
what am I doing wrong here? In javascript is there a way to differentiate between numeric and string variables?
thanks.