在加载添加运算符的表单之前,我必须使用 php 文件 addoperator.php 调用 Web 服务,该文件返回给我一个包含组织、位置、建筑值的 json,我已将该 json 值转换为下拉列表,现在这些下拉菜单必须在添加操作员表单中的字段组织、位置和建筑物下。
她是 addoperator.php 的代码
<?php
session_start();
$url='webservice url';
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($useridofuser));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$response= curl_exec($ch);
echo('\n'."Server response : \n \n".$response);
curl_close($ch);
//parsing the json response from server
$jsonde="$response";
$org = array();
$loc = array();
$bui = array();
$items = json_decode($response);
foreach( $items as $each ){
$loc[]=$each->location[0]->name;
$bui[]=$each->location[0]->building[0];
$org[]=$each->name;
}
?>
<select name="category_id">
<option value=""></option>
<?php
foreach($org as $key=>$val)
{?>
<option value="<?php echo $key; ?>"><?php echo $val; ?></option>
<?php
}
?>
</select>
<select name="category_id">
<option value=""></option>
<?php
foreach($loc as $key=>$val)
{?>
<option value="<?php echo $key; ?>"><?php echo $val; ?></option>
<?php
}
?>
</select>
<select name="category_id">
<option value=""></option>
<?php
foreach($bui as $key=>$val)
{?>
<option value="<?php echo $key; ?>"><?php echo $val; ?></option>
<?php
}
?>
</select>
addoperatorui.php 的用户界面是 addoperatorui.php(如何将 addoperatorui.php 的下拉菜单带到 addoperatorui.php
<h3>ADD ROUTER </h3>
</div>
<form method="post" action="login.php" >
<table border="0" >
<tr><td>Username</td>
<td><input type="text" name="userid"></td></tr>
<tr><td>Password</td>
<td><input name="password" type="password"></td></tr>
<tr><td>Confirm Password</td>
<td><input name="password1" type="password"></td></tr>
<tr><td>Email</td>
<td><input name="email" type="email"></td></tr>
<tr><td>Organisation Name</td>
<td><input name="orgname" type="text"></td></tr>
<tr><td>Location</td>
<td><input name="location" type="text"></td></tr>
<tr><td>Building</td>
<td><input name="building" type="text"></td></tr>
<tr><td>Department</td>
<td><input name="department" type="text"></td></tr>
<?php
$oneYearOn = date('Y-m-d',strtotime(date("Y-m-d", mktime()) . " + 7300 day"));
//echo $oneYearOn;
$oneYearOn1=date('Y-m-d',strtotime(date("Y-m-d", mktime()) . " + 40day"));
//echo $oneYearOn1;
?>
<tr><td>Sub Category</td>
<td>
<select id="Ultra" onchange="run()"> <!--Call run() function-->
<option value="0">Select</option>
<option value="<?=$oneYearOn?>">Employee</option>
<option value="<?=$oneYearOn1?>">Temporary</option>
</select>
</td>
</tr> <tr><td>First Name</td>
<td><input name="firstname" type="text"></td></tr>
<tr><td>Last Name</td>
<td><input name="lastname" type="text"></td></tr>
<tr><td>Land Phone</td>
<td><input name="landphone" type="number"></td></tr>
<tr><td>Mobile</td>
<td><input name="mobile" type="number"></td></tr>
<tr><td>Expiry date</td>
<?php
?>
<td><input type="text" id="srt" placeholder="get value on option select"><br></td></tr>
<tr><td>Opcode</td>
<td><input name="opcode" type="text"></td></tr>
<tr><td>Expiry date</td>
<td><input name="expirydate" type="date"></td></tr>
<tr><td>Image</label></td>
<td><input type="file" name="image"></td></tr>
<tr><td><input type="submit" value="Submit"/></td></tr>
</table>
</form>