php - I have to call a javascript function which is located in same file -
after clicking send button. have pass these parameters function not working expected. if understand please help. below button , function...
$pm_ui .= '<button type="submit" id="pmbtn" onclick="postpm(\''.$u.'\',\''.$log_username.'\',\'$pmsubject\',\'$pmtext\')">send</button>'; function postpm(tuser,fuser,subject,ta){ var data = _(ta).value; var data2 = _(subject).value; if(data == "" || data2 == ""){ alert("fill fields"); return false; } _("pmbtn").disabled = true; var ajax = ajaxobj("post", "php_parsers/pm_system.php"); ajax.onreadystatechange = function() { if(ajaxreturn(ajax) == true) { if(ajax.responsetext == "pm_sent"){ alert("message has been sent."); _("pmbtn").disabled = false; _(ta).value = ""; _(subject).value = ""; } else { alert(ajax.responsetext); } } } ajax.send("action=new_pm&fuser="+fuser+"&tuser="+tuser+"&data="+data+"&data2="+data2); } but whenever click on 'send' button not triggering function code following. if missing please me take attention there..(button not responding thing...)
ok, made test , works
<?php $u = 'u'; $log_username = 'log_username'; $pmsubject = 5; $pmtext = 4; echo '<button type="submit" id="pmbtn" onclick="postpm(\''.$u.'\',\''.$log_username.'\','.$pmsubject.','.$pmtext.')">send</button>'; ?> <script> var postpm=function (tuser,fuser,subject,ta){ console.log(tuser); console.log(fuser); console.log(subject); console.log(ta); } </script> i hope helps
Comments
Post a Comment