简体   繁体   English

如何将我的脚本值从javascript显示到php

[英]How do I show my script value from javascript to php

I have a script ( javascript ) 我有一个脚本( javascript

<script>
$(function(){
    $(".editagunan").click(function(){
        var id_agunan = $(this).attr("data_id_agunan"); 

        $("#value_id_agunan").val(id_agunan);

        $("#myModalEdit").modal("show");
    });
});
</script>

how to display 'value_id_agunan' from javascript to php 如何从javascript到php显示'value_id_agunan'

<?php echo id="value_id_agunan" ?>

but the script is wrong, how to fix ? 但是剧本错了,怎么解决? Thanks 谢谢

Assuming, you are asking on how to write html inside a php file. 假设,你问的是如何在php文件中编写html。

Just write HTML directly, like this: 只需直接编写HTML,如下所示:

<p id="value_id_agunan"></p> 

If you want to show the above html code on some condition then use php like this: 如果你想在某些条件下显示上面的HTML代码,那么使用这样的PHP:

<?php if(showParagraph){ /* some variable */ ?>
    <p id="value_id_agunan"></p>
<?php } ?> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM