PHP如何调用js中的函数
我做了个审核的功能这是我php代码:{if $t.shen==1}
审核通过
{else if $t.shen==3}
审核未通过
{else}
<input type="button" style="background-color: #00a2d4;color: #ffffff;" id="butn" value="审核"/>
<?php
if($myts==1)
{
$ci->db->set('shen',1)->where('id',$t.id)->update(SITE_ID.'_form_companymessage');
这里要调用js函数changehref1()这个地方怎么写?
}
else if($myts==3)
{
$ci->db->set('shen',3)->where('id',$t.id)->update(SITE_ID.'_form_companymessage');
这里要调用js函数changehref2()这个地方怎么写?
}else
{
$ci->db->set('shen',2)->where('id',$t.id)->update(SITE_ID.'_form_companymessage');
这里要调用js函数changehref3()这个地方怎么写?
}
?>
{/if}
这是我js代码:<script>
function changehref1()
{
document.getElementById("Id1").setAttribute("href","/admin.php?c=form_companymessage&m=index");
}
function changehref2()
{
document.getElementById("Id2").setAttribute("href","/admin.php?c=form_companymessage&m=index");
}
function changehref3()
{
document.getElementById("Id3").setAttribute("href","/admin.php?c=form_companymessage&m=index");
}
</script>
php是在服务器端执行的js是在客户端执行的 所以你这个思路有点清奇。。。 你只可能用php来控制是否输出某段js代码,而不可能用php调用js。其实更好的方式是用ajax来进行交互
页:
[1]