Forum Moderators: open

Message Too Old, No Replies

Java Trimming my PHP Variable

         

theriddla1019

2:21 pm on May 12, 2004 (gmt 0)

10+ Year Member



Im passing a cookie value set by php to a java function for onclick. Displaying the cookie value as a php variable works fine. Eg:

<?=$_COOKIE['lastmr']?>

Will give
00000140

But when i put this into my onclick function:

<script Language="JavaScript">
function LastVal()
{
document.add.MR.value=<?=$_COOKIE['lastmr']?>;
}
</script>

called with :

<a href="#" onClick="LastVal()">last</a>

When I "click" it strips the 0's giving me:

140 instead of 00000140.

And unfortunatelly i need those zero's in there to search for the right product.
Are there any arguments i can give the function to make it not strip 0's?
Please help!
Thanx :)

Bernard Marx

2:36 pm on May 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a stab in the dark:
document.add.MR.value= "" + <?=$_COOKIE['lastmr']?>;

theriddla1019

2:43 pm on May 12, 2004 (gmt 0)

10+ Year Member



That doesnt work but you gave me the insight to see what was wrong with my code!

I forgot to put ""'s around my variable.

document.add.MR.value="<?=$_COOKIE['lastmr']?>";

Thanks :P