简体   繁体   English

使用按钮将数据从PHP发送到Java脚本

[英]Send data with button from php to java script

Hi i want to send data from php code to java script and java script code send themes to another php file like below: 嗨,我想将数据从php代码发送到Java脚本,而Java脚本代码将主题发送到另一个php文件,如下所示:

<td><input type="submit" value="Edit" name="edit" id="edit" onclick="sendToEdit(<?php echo $row['pID'] ?>,<?php echo $row['phID']?>,<?php echo $testHistoryDate ?>,<?php echo (string)$type ?>);"  />

when i debug with firebug i see php code make true values in the php area but when send themes to java script can't send <?php echo $testHistoryDate ?>,<?php echo (string)$type ?>); 当我用firebug调试时,我看到php代码在php区域中使真值,但是将主题发送到Java脚本时无法发送<?php echo $testHistoryDate ?>,<?php echo (string)$type ?>); true values and send another date for testHistoryDate and true value for (string)$type but fire bug make below error: 真值并发送testHistoryDate的另一个日期和(string)$type真值,但引发错误,出现以下错误:

Phibrinozhen is not defined

[Break On This Error] [中断此错误]

sendToEdit(9004, 119002, 1997, Phibrinozhen); sendToEdit(9004,119002,1997,Phibrinozhen);
in the above code 1997 isn't true value true value is: 在上面的代码1997中不是true value true value是:

onclick="sendToEdit(9004,119002,2010-10-03,Phibrinozhen);"

that php make but java script java script code 该PHP使,但Java脚本Java脚本代码

function sendToEdit(pID,phID,thDate,type) 

The error is occurring because you trying to pass string literals without telling JavaScript they are strings. 发生错误是因为您尝试传递字符串文字而不告诉JavaScript它们是字符串。 You need to escape at least your final two parameters with quotes: '2010-10-0', 'Phibrinozhen' . 您至少需要用引号将最后两个参数转义: '2010-10-0', 'Phibrinozhen'

<td><input type="submit" value="Edit" name="edit" id="edit" onclick="sendToEdit('<?php echo $row['pID'] ?>','<?php echo $row['phID']?>','<?php echo $testHistoryDate ?>','<?php echo (string)$type ?>');"  />

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

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