2

我有一个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> 

任何帮助将不胜感激..谢谢

4

3 回答 3

0

正如你用 jquery 标记的那样,我建议使用jquery post

$.get( "some.php", function( data ) {
  $( "#membergroupsname" ).html( data );
});

http://api.jquery.com/jQuery.get/

于 2013-10-03T07:53:12.640 回答
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 ------>
于 2013-10-03T08:02:10.557 回答
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");
});
});
});
于 2013-10-31T02:55:52.337 回答