【发布时间】:2012-05-05 11:57:19
【问题描述】:
我有一个巨大的表单,在表单的一部分我想使用 js 向数据库插入一些值。我可能不清楚如何提出这个问题,但我的需求是: 假设,我在数据库 table1、table2 中有两个表。在 html 表单中:
<select name="tab1" id="tab1">
<?php while($row = fetch from table 1){ ?>
<option value"<?=$row['name']?>" name="option1"><?=$row['name']?></option>
<?php } ?>
</select>
<input type="file" name="file">
<input type="button" name="button" onclick="submit_form(true,'');">
现在,我想将 $row['name'] 值传递给 javascript 中的 submit_form() 函数。 javascript 代码将检查该值并将其返回到表单以提交它。我的问题是,由于 table1 中的 $row['name'] 在 while 循环内,我无法将值传递给 javascript。如果表单很小,我可以使用提交按钮并检查 $_POST('submit') 类型。我想将这种形式的 $row['name'] 插入到 table2 作为与名称关联的文件名。
【问题讨论】:
标签: php javascript jquery onclick