echo "<form name=\"form1\" method=\"post\" action=\"\">\n";
echo "<select name=\"roll_1\" id=\"roll_1\"size=\"3\">\n";
echo " <option value=\"1\">1</option>\n";
echo " <option value=\"2\">2</option>\n";
echo " <option value=\"3\">3</option>\n"; <--- User select how to pick the prev and next value
echo " <option value=\"4\">8</option>\n";
echo " <option value=\"5\">9</option>\n";
echo " <option value=\"6\">6</option>\n";
echo "</select>\n";
echo "<select name=\"roll_2\" id=\"roll_2\"size=\"3\">\n";
echo " <option value=\"1\">1</option>\n";
echo " <option value=\"2\">2</option>\n";
echo " <option value=\"3\">3</option>\n";
echo " <option value=\"1\">4</option>\n";
echo " <option value=\"2\">7</option>\n";
echo " <option value=\"3\">8</option>\n";
echo "</select>\n";
echo '<input type="submit" name="Send" id="Send" class="button" value="Send">';
echo "</form>\n";
$a = $_POST['roll_1'];
$b = $_POST['roll_2'];
如何在选择后选择prev和next值并存储在mysql中.. 如果我选择选项3如何选择选择2和选项4
答案 0 :(得分:0)
在表单中创建一个隐藏的输入框,如下所示:
<input type="hidden" name="roll_1_next" id="roll_1_next">
<input type="hidden" name="roll_1_prev" id="roll_1_prev">
并添加以下js,它将获取下一个和上一个下拉值并放入隐藏框中。
var next = jQuery('#roll_1 option:selected').next().attr('value');
var prev = jQuery('#roll_1 option:selected').prev().attr('value');
jQuery("#roll_1_next").val(next);
jQuery("#roll_1_prev").val(prev);
在PHP中你可以得到它:
$next = $_POST['roll_1_next'];
$prev = $_POST['roll_1_prev'];