Jump to content

Weirdest Javascript error. ever!


Monkuar

Recommended Posts

Ok look:

 

//Send Gold time baby here we come my nig'a @@
function nGold($username="") {
global $ibforums;
$IPBHTML = "";


$IPBHTML .= <<<EOF
<img src="gold.gif" style="cursor:hand"  style="cursor:hand" onclick="sendGold({$username},event)""></a>
{$username}
EOF;

return $IPBHTML;
}

 

 

That's my skin_xx.php file for :

 

$row['nGold'] = $this->html->nGold($row['name']);

 

 

 

Here is my JAVASCRIPT FILE:

 

var goldOn = false;
var gAuthkey='';
function sendGold(username,event) {
var itm = expMenu("nGold");
goldOn = !goldOn;
if(goldOn && itm) {
	if(itm.innerHTML=="") itm.innerHTML = "<legend>Quick Send Forum Gold<a href='javascript:sendGold()' class='hs'><img src='images!!/x.gif'></a></legend><form name='sendGoldForm' action='index.php?&act=shop&func=transfer_money&code=send' method='post' target='_blank'><input type='hidden' name='username' value='0'><table class='ftbt'><tr><td align=right>Gold Give Amount:</td><td><input type=text name='money' maxlength=7 size=7></td></tr><tr><td align=right>Optional Comments:</td><td><textarea name=post cols=20 rows=4></textarea></td></tr><tr><td align=center colspan=2><br><input type='submit' value='Submit Gold Transfer' name='submit' onclick='sendGold()'><br><br></td></tr><tr><td align=center colspan=2><a href='index.php?act=purchaseGold'>Purchase More Forum Gold</a></td></tr></table></form>";
	itm.style.left=event.clientX + (window.pageXOffset!=undefined?window.pageXOffset:document.body.scrollLeft)+"px";
	itm.style.top=event.clientY + (window.pageYOffset!=undefined?window.pageYOffset:document.body.scrollTop)+"px";
	itm.style.zIndex="100";
	sendGoldForm.username.value=username;
}
}

 

It wont work if I use onclick="sendGold({$username},event)"...

 

I have to use a number like onclick="sendGold(215125,event)"

 

or any number to make it work?? Because then if I do let's say

 

onclick="sendGold(monkuar,event)"

 

then it just gives me this...

 

monkuar is not defined
[break on this error] sendGold(monkuar, event);

 

but i need it to be work with letters and not just numbers because my code in javascript i posted above does this:

 

<legend>Quick Send Forum Gold<a href='javascript:sendGold()' class='hs'><img src='images!!/x.gif'></a></legend><form name='sendGoldForm' action='index.php?&act=shop&func=transfer_money&code=send' method='post' target='_blank'>[u][i][b]<input type='hidden' name='username' value='0'>[/b][/i][/u]<table class='ftbt'><tr><td align=right>Gold Give Amount:</td><td><input type=text name='money' maxlength=7 size=7></td></tr><tr><td align=right>Optional Comments:</td><td><textarea name=post cols=20 rows=4></textarea></td></tr><tr><td align=center colspan=2><br><input type='submit' value='Submit Gold Transfer' name='submit' onclick='sendGold()'><br><br></td></tr><tr><td align=center colspan=2><a href='index.php?act=purchaseGold'>Purchase More Forum Gold</a></td></tr></table></form>";

 

The bolded part is wat i need the value= to be the members name.. but javascript wont let me do that only letters? Anyone else confused like me? Help!

Link to comment
https://forums.phpfreaks.com/topic/157315-weirdest-javascript-error-ever/
Share on other sites

I did:

 

<img src="gold.gif" style="cursor:hand"  style="cursor:hand" onclick="sendGold("{$username}",event)""></a>

 

Now I got :

 

Btw {$username} is a user of who posted on the side of my forum.

 

And i stil get erorr:

 

 

syntax error
[break on this error] sendGold(

 

All i want to do is to beable to use letters instead of numbers here:

 

function sendGold(id,event) {

 

Like id is just a variable but it only accepts numbers i want to use letters :( i tried quote and also here

 

sendGoldForm.username.value=id;

 

i want that to accept letters too :P

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.