Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中基于下拉列表重新加载页面_Php_Javascript - Fatal编程技术网

在php中基于下拉列表重新加载页面

在php中基于下拉列表重新加载页面,php,javascript,Php,Javascript,在我的页面上有一个下拉列表,在同一页面上有一个html表,还有一个列,其值来自数据库表。 下拉列表有3个选项。i、 e.联邦、州和地方 我希望当我选择任何选项时,我的页面在同一页面上重新加载,并更改表中的列值,该表的值在数据库中为联邦值、州值和本地值设置 <select name="election" id="text" > <option value="federal"> Federal </option> &

在我的页面上有一个下拉列表,在同一页面上有一个html表,还有一个列,其值来自数据库表。 下拉列表有3个选项。i、 e.联邦、州和地方 我希望当我选择任何选项时,我的页面在同一页面上重新加载,并更改表中的列值,该表的值在数据库中为联邦值、州值和本地值设置

<select name="election" id="text" >
            <option value="federal"> Federal </option>
            <option value="state"> State </option>
            <option value="local"> Local </option>
          </select>

this is dropdown list code


    <form name="form1">
              <table width="90%" border="0" cellpadding="1" cellspacing="1" bgcolor="#c0c0c0">
                <tr>
                  <td width="9%" align="center" bgcolor="#FFFFFF" class="head01"><input type="checkbox" value="1" onClick="$('input[name*=\'selected\']').attr('checked', this.checked);" id="check_all" name="data[Farm][check_all]" >
                  </td>
                  <td width="7%" align="center" bgcolor="#FFFFFF" class="head01">Sr. No. </td>
                  <td width="25%" align="center" bgcolor="#FFFFFF" class="head01">Leader name</td>
                  <td width="13%" align="center" bgcolor="#FFFFFF" class="head01">Facebook Like</td>
                  <td width="11%" align="center" bgcolor="#FFFFFF" class="head01">Twitter Like</td>
                  <td width="10%" align="center" bgcolor="#FFFFFF" class="head01" id="value"> Value</td>
                  <td width="12%" align="center" bgcolor="#FFFFFF" class="head01">View Profile</td>
                  <td width="15%" align="center" bgcolor="#FFFFFF" class="head01">Select PM</td>
                </tr>


    <?php
    $election=$_REQUEST['election'];
     $result = mysql_query("SELECT * FROM leader_info"); 
     $i=1;
        while($row = mysql_fetch_assoc($result))
          {             
    ?>
                <tr>
                  <td bgcolor="#FFFFFF" align="center"><input type="hidden" value="0" id="chkids" name="chkid[0]">
                    <input type="checkbox" id="ChkIds" value="<?php echo $row['leader_id']; ?>" name="selected[]" onChange="myFunction(this)" class="<?php echo $row['state_point'];?>">
                  </td>
                  <td bgcolor="#FFFFFF" align="center"><span class="subdetails"><?php echo $i++; ?></span></td>
                  <td bgcolor="#FFFFFF" align="left"><span class="subdetails"><?php echo $row['leader_name']; ?></span></td>
                  <td bgcolor="#FFFFFF" align="left"><?php echo $row['facebook']; ?></td>
                  <td bgcolor="#FFFFFF" align="left"><?php echo $row['twitter']; ?></td>
                  <td bgcolor="#FFFFFF" align="left" class="<?php echo $row['state_point'];?>" ><?php echo $row['state_point'];?>



     </td>
                  <td align="center" bgcolor="#FFFFFF"><a href='#'><img style='vertical-align:bottom;' src='images/view profile.png' width='10' height='10' border='0'></td>
                  <td align="center" bgcolor="#FFFFFF"><input type="radio" name="pm" value="pm"></td>
                </tr>

    <?php  } ?>
    <tr>
                  <td align="center" bgcolor="#FFFFFF">Remaining Budget : </td>
                  <td align="center" bgcolor="#FFFFFF"><span id="total" class="0">1000</span></td>
                  <td>
                  </td>

                </tr>
                <tr>
                  <td align="center" bgcolor="#FFFFFF"><input type="submit" name="add"  value="Add Team"> </td>
                  <td align="center" bgcolor="#FFFFFF"><input type="reset"  value="Clear Team" onClick="javascript:changeTextToBlack();"></td>
                </tr>
              </table>
    </form>

联邦的
陈述
地方的
这是下拉列表代码
高级专员。
领导姓名
像Facebook
像推特一样
价值
视图配置文件
选择PM
剩余预算:
1000
这是我的表代码,我想在中进行更改
选择下拉列表时,它会自动将值更改为本地、联邦而不是州,其他字段保持不变,只有在值列中更改才能执行此操作。使用JavaScript/Ajax和HTML:

<select id="text" name="hub" onChange="refine_search();">
    <option value="test1">test1</test1>
    <option value="test2">test2</test2>
    <option value="test3">test3</test3>
</select>
这将完成所需的工作

试试这个

<select id="text" name="sel" onChange="reloadPage();">
        <option value="a" <? echo ($_GET['sel'] == 'a' ? 'selected="selected"' : '') ?> >test1</test1>
        <option value="b" <? echo ($_GET['sel'] == 'b' ? 'selected="selected"' : '') ?>>test2</test2>

    </select>

表单提交时,sel选项值将自动选择,无需AJAX

请把你的密码贴在这里。。。
<select id="text" name="sel" onChange="reloadPage();">
        <option value="a" <? echo ($_GET['sel'] == 'a' ? 'selected="selected"' : '') ?> >test1</test1>
        <option value="b" <? echo ($_GET['sel'] == 'b' ? 'selected="selected"' : '') ?>>test2</test2>

    </select>
function reloadPage()
{
    document.frm_change.method = 'get';
    document.frm_change.submit();
}