简体   繁体   English

如何在jQuery中使用分号

[英]How to use semicolon in jQuery

I have the following line : 我有以下几行:

html += '<td><select value="<?php echo $location; ?>" class="form-control" name="data[InvoiceDetail]['+i+'][location]" id="location_'+i+'" placeholder="Location"></td>';

That is a part of a function that adds multiple dynamically added table data and rows. 这是添加多个动态添加的表数据和行的功能的一部分。 I have other entries that do not mess up the script, such as : 我还有其他不会弄乱脚本的条目,例如:

html += '<input type="hidden" id="stock_'+i+'"/>';

I think the problem of the script not working is the ";" 我认为脚本无法正常工作的问题是“;” after $location, but I do not know how to alter the script to allow this? 在$ location之后,但我不知道如何更改脚本以允许这样做?

So, boiling everything down, how do I add the above line to the dynamically added rows, while retaining the values? 因此,将所有内容简化,如何在保留值的同时将上述行添加到动态添加的行中?

Thanks! 谢谢!

It looks like you are dynamically adding PHP content to your page in the client (browser), but PHP needs to be executed on the server. 看起来您正在向客户端(浏览器)的页面中动态添加PHP内容,但是PHP需要在服务器上执行。

Perhaps you could use ajax to request the value of "location" from the server, and then dynamically add it. 也许您可以使用ajax从服务器请求“位置”的值,然后动态添加它。

This may provide a nice example: using jquery $.ajax to call a PHP function 这可能提供一个很好的示例: 使用jquery $ .ajax调用PHP函数

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

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