douyuan9512 2016-04-06 08:10
浏览 54

按下按钮时更改$ _post ['value']

I'm having the following problem: Ihave 3 dropdown lists. When I press the button I get 3 $_POST variables. Also, I have a function with 3 variables needed to get the outcome like this function(x,y,z) in wachtwoord dropdown list, and I save the options x,y,z in a serialized array as a history.

Everything works perfectly, but when I load the update page I want to unserialize the array, and extract the 3 values for each dropdown list, and I want to display the previews outcome before I change something and get the new. The problem is that with an if statement it locks the $_POST values and when I press the button it keeps the same without discarding the old ones first.

My update.php page:

echo '<div class="form-inline">
     <div class="form-group">
         <label for="name1">name1:</label>
         <select name="name1[]" style="width:auto;" class="form-control">
             <option value="0" '.((isset($_POST['name1'][0]) && $_POST['name1'][0] == 0)?'selected="selected"':'').'>option1</option>
             <option value="3" '.((isset($_POST['name1'][0]) && $_POST['name1'][0] == 3)?'selected="selected"':'').'>option2</option>
         </select>
            <label for="name2">name2:</label>
         <select name="name2[]" style="width:auto;" class="form-control">
            <option value="option1" '.((isset($_POST['name2'][0]) && $_POST['name2'][0] == "option1")?'selected="selected"':'').'>option1</option>
            <option value="option2" '.((isset($_POST['name2'][0]) && $_POST['name2'][0] == "option2")?'selected="selected"':'').'>option2</option>
         </select>
            <label for="name3">name3:</label>
         <select name="name3[]" style="width:auto;" class="form-control">
            <option value="0" '.((isset($_POST['name3'][0]) && $_POST['name3'][0] == 0)?'selected="selected"':'').'>optionA</option>
            <option value="1" '.((isset($_POST['name3'][0]) && $_POST['name3'][0] == 1)?'selected="selected"':'').'>optionB</option>
            <option value="2" '.((isset($_POST['name3'][0]) && $_POST['name3'][0] == 2)?'selected="selected"':'').'>optionC</option>
        </select>
    </div>
</div>';

My history array:

$history = unserialize($results[0]->history);
 $name1 = $history[name1];
 $name2 = $history[name2];
 $name3 = $history[name3];

As I said, an if statement for one of three lists:

if(isset($name1) && $name1 == 0){$_POST['name1'][0] = 0;
}else{$_POST['name1'][0] = 3;}

To summarize: [page loads]->[dropdown lists are OK with the history values] -X->[change 1 or more dropdown lists and press the button keeps the old values and NOT the new ones.]

Could you please help me? Thanks in advance.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数