Jump to content

I can't call this function


Fiqhi

Recommended Posts

im trying to call a function from a button like this

<a href="javascript:checker(\'checker_r.php\',\'a\')"><img src="images/accept.png" alt="Accept" /></a>

Calling This Function

function checker(file,type) {
	var mail_tot;
	$("input[@name='mchk[]']:checked").each(function() {
		var sel_mail=$(this).val();
		if((mail_tot=='')||(mail_tot=='undefined')){
			mail_tot = sel_mail;
		}else{
			mail_tot = sel_mail+','+mail_tot;
		}
	});
	var a=$.get("checker_stat.php", {
		mail_tot:mail_tot,type:type},
		function(data){
			ShowSearch('',file);
                       
		}
	);
}

If i clicked the button nothing happens. This function will do some task to selected checkbox

Link to comment
Share on other sites

After deleting "\" i got

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in

These buttons are inside single quote

if ($idgroups!='') echo '
<div class="btn_holder">
<a href="javascript:procfrom(\'checker_r.php\',\'a\')"><img src="images/accept.png" alt="Accept" /></a> 
<a href="javascript:procfrom(\'checker_r.php\',\'d\')"><img src="images/decline.png" alt="Decline" /></a>
</div>
<div class="next_prev"><span id="naav">'.$paging->print_link().'</span> <span>'.$data[start].' - '.$data[end].' of Total '.$data[total].' Message</span></div>
';
Edited by Fiqhi
Link to comment
Share on other sites

then you didn't post the original code properly. The way you posted it made it seem like is was html, when in fact you are echo(ing) it from php. Try escaping the outer quotes:

echo '<a href=\'javascript:checker("checker_r.php","a")\'><img src="images/accept.png" alt="Accept" /></a>';
Link to comment
Share on other sites

i've tried to change it into this

if ($idgroups!='') echo '
<div class=\'btn_holder\'>
<a href=\'javascript:procfrom("checker_r.php","a")\'><img src=\'images/accept.png\' alt=\'Accept\' /></a> 
<a href=\'javascript:procfrom("checker_r.php","d")\'><img src=\'images/decline.png\' alt=\'Decline\' /></a>
</div>
<div class=\'next_prev\'><span id=\'naav\>'.$paging->print_link().'</span> <span>'.$data[start].' - '.$data[end].' of Total '.$data[total].' Message</span></div>
';

it compiles but still no response when clicking

Link to comment
Share on other sites

here's proof that it does work:

 

 

<html>
<head><script>
function checker(file,type) {
alert(file+' '+type);
}</script>
</head>
<body>
<?php
echo '<a href=\'javascript:checker("checker_r.php","a")\'>test</a>';
?>
</body>
</html>

replace your javascript function with a single echo like I did. If you get a popup, then the error is somewhere in the javascript function and not the button call.

Edited by WebStyles
Link to comment
Share on other sites

i dnt get a popup if the function is in the different file from the button.

if it's in same file, the popup show up

 

and if im using my own function, both won't work. still not triggered. Maybe because my function call others function in different file too

Edited by Fiqhi
Link to comment
Share on other sites

ahh.. i got the real problem...

 

Thanks to Ch0cu3r

it's in 

function checker(file,type) {
	var mail_tot;
	$("input[@name='mchk[]']:checked").each(function() {
		var sel_mail=$(this).val();
		if((mail_tot=='')||(mail_tot=='undefined')){
			mail_tot = sel_mail;
		}else{
			mail_tot = sel_mail+','+mail_tot;
		}
	});
	var a=$.get("checker_stat.php", {
		mail_tot:mail_tot,type:type},
		function(data){
			ShowSearch('',file);
                       
		}
	);
}

Uncaught Error: Syntax error, unrecognized expression: input[@name='mchk[]']:checked

 

are my syntax wrong? i need this function to get id of selected checkbox

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.