我有一个内置select
输入的表单。当option
更改时,将处理表单(使用php)并在<form>
下显示该过程的结果。
怎么做?
这是我的html表单代码:
<tr>
<td>
<form name="group" id="form1" method="post">
<select name="group" id="group" onChange="something()">
<?php foreach ($userGroups['data'] as $groups) {
echo "<option value=\"".$groups['id']."\">".$groups['name']."</option>";
}?>
</select>
</form>
</td>
</tr>
<tr>
<td>
<?php //PROCESSING THE FORM
if ($_POST) {
$groupId = $_POST['group'];
$groupmember = $facebook->api('/'.$groupId.'/members');
$membergroup = $groupmember['data'];
foreach ($membergroup as $membergroups) {
$membergroupsname = $membergroups['name'];
}
}
?>
<!---- THE PLACE WHERE $membergroupsname DISPLAYED ------>
</td>
</tr>
非常感谢任何帮助..谢谢
答案 0 :(得分:0)
当你用jquery标记时,我建议使用jquery post
$.get( "some.php", function( data ) {
$( "#membergroupsname" ).html( data );
});
答案 1 :(得分:0)
试用此代码
<强> JQuery的强>
function handleSelect(elm){
window.location = elm.value;
}
<强> PHP 强>
<form name="group" id="form1" method="post">
<select name="group" id="group" onChange="handleSelect(this)">
<?php foreach ($userGroups['data'] as $groups) {
echo "<option value=\"index.php?groupname=".$groups['id']."\">".$groups['name']."</option>";
}?>
</select>
</form>
</td>
</tr>
<tr>
<td>
<?php //PROCESSING THE FORM
if ($_GET) {
$groupId = $_GET ['group'];
$groupmember = $facebook->api('/'.$groupId.'/members');
$membergroup = $groupmember['data'];
foreach ($membergroup as $membergroups) {
$membergroupsname = $membergroups['name'];
}
}
?>
</form>
<!---- THE PLACE WHERE $membergroupsname DISPLAYED ------>
答案 2 :(得分:0)
使用jquery .change
jQuery('#group').change(function() {
var id_group = this.value;
var memberjson = "fetchmember.php?group="+id_group;
jQuery("#fetchmember").html('<img src="./templates/standard/images/ajax-loader.gif">');
jQuery.getJSON(memberjson,function(data){
jQuery("#fetchmember").empty();
jQuery.each(data, function(i, item) {
jQuery("#fetchmember").append("write your html");
});
});
});