使用jquery添加表单的一部分

时间:2015-10-29 18:36:14

标签: php jquery ajax

我有一个名为st_record_rcs.php的php表单。它有一个调用showFirstDiv(str)的下拉菜单:

function showFirstDiv(str) {
$('#div1').load('st_infopage.php?info_div1='+str); 
}



$query11 = "SELECT name, contact, street, city, state, zip, country, phone, email,ID FROM st_profiles WHERE type='S' ORDER BY `st_profiles` . `name` ASC "
or logfile($comment1,$random,$location,$access,$first,$is_address,$is_vendor,$is_inventory,$is_admin);

$result4 = $mysqli->query($query11);
$count1 = '0';
$column_count = mysqli_field_count($mysqli);
while ($row2 = mysqli_fetch_array($result4, MYSQLI_BOTH))
{
for ($column_num = 0; $column_num < $column_count; $column_num++)
switch($column_num) {
case $column_num:
break;
} // END FOR LOOP

if ($count1 == '0') {
print ("<select name='shipper_addresses' onchange=\"showFirstDiv(this.value); \"  size='1' style='width:150; height:19; font-size:12px;' TABINDEX='1'>
<option value=''></option><option value='ADD'>[ADD NEW]</option>"); 

} 
print ("<option value='$row2[9]'>$row2[0]</option>");
$count1 = $count1 + 1;
} // END WHILE LOOP


print ("</select></td></tr>");

print ("<tr><td colspan='2'><div id='div1'><p> </p> </div></td></tr>");

这是FILE st_infopage.php

if ($_GET[info_div1]) {

if ($_GET[info_div1] != 'ADD') {    
$query11 = "SELECT street,ID FROM st_profiles WHERE ID='$_GET[info_div1]' ORDER BY `st_profiles` . `name` ASC "
or logfile($comment1,$random,$location,$access,$first,$is_address,$is_vendor,$is_inventory,$is_admin);

$result_name_check4  = $mysqli->query($query11);
$passcheck2 = mysqli_fetch_array($result_name_check4, MYSQLI_NUM);    /* numeric array - meaning $passcheck[0] instead of $passcheck[user_id]*/

$shipper_street = $passcheck2[0]; 
} else {
$shipper_street = ''; 
}
echo "<table><input type='hidden' name='shipper_id' value='$shipper_id'>
<tr><td width='105' bgcolor='$shipstreet_color'>Shipper Name:</td><td><input type=text name='shipper_street' size=40 maxlength=40 style='width:150; height:18; font-size:10px;' value='$shipper_street' TABINDEX='2'></td></tr>
</table>";
    }

当我从下拉列表中选择值st_infopage.php时,一切正常,托运人信息会在我的表单中正确显示在标签内。问题是当我从st_record_rcs.php提交表单时,标记内的值不会POST。我没有对提交程序做任何事情。

<form name='theForm' action='st_record_rcs.php' method=post >. 

除了div标签中的内容之外,所有其他表单值都会通过。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

所以,来自:

<form name='theForm' action='st_record_rcs.php' method=post >

我注意到该表单包含 method="POST" action="st_record_rcs.php" 属性;但 $_POST["something"] 中没有相应的 st_record_rcs.php 来处理已解雇的HTTP请求。所以,下面是我对问题解决方案的建议,希望它会引导你走上正确的道路。

我们的<form>假设:

<form name='theForm' action='st_record_rcs.php' method='POST'>
     <input type="text" name="userID">
     <button type="submit" name="submitRecordButton">Submit Record</button>
</form>

我们的 st_record_rcs.php 会有:

if(isset($_POST["submitRecordButton"])) {
     $userID = $_POST["userID"];
     // Do amazing things... or 

     /* for debugging's sake */
     echo $userID;
     exit;
}