form提交后,action中怎么获取select下拉框的选中值

点击按钮后如果选择.com表单应该是 http://我的域名/nav/c1.php?id=
如果选择.cn应该是 http://我的域名/nav/c2.php?id=

                            小白不懂 想问下怎么实现
 <form action="这里应该填什么才能保证选择其他选项的时候自动变成option value后的内容" method="get" name="form">
                 <div class="form-group">
                    <div class="input-group">
                     <input type="text" name="id" class="form-control" placeholder="请输入删除后缀的域名">
                      <div class="input-group-addon">
                      <select id="select" onchange="change();">
                        <option value="./nav/c1.php" selected>.com</option>
                        <option value="./nav/c2.php">.cn</option>
                        <option value="./nav/c3.php">.cc</option>
                        <option value="./nav/c4.php">.me</option>
                        <option value="./nav/c5.php">.pw</option>
                        <option value="./nav/c6.php">.top</option>
                        <option value="./nav/c7.php">.net</option>
                        <option value="./nav/c8.php">.bid</option>
              <option value="./nav/c9.php">.online</option>
 <option value="./nav/a1.php">.xyz</option>
                       </select>
                      </div>
                    </div>
                 </div>
                <button type="submit" class="btn btn-success btn-block">生成短链接</button>

5个回答

你试试在你的中添加一个name的属性,id属性是用于JS的,然后用下面的代码
String Select=request.getParameter("select");
最后试试输出<%= Select%>

在你的中添加一个name的属性,id属性是用于JS的,然后用下面的代码
String Select=request.getParameter("select");
最后试试输出<%= Sele

在select标签添加一个属性name="select",在Servlet中写上String select=request.getParmeter("select");
然后在Servlet中打印一些select,看看有没有获得jsp页面中的select

使用jquery

form 里添加一个id, id="form_id"

$("#select").change(function() {
$("#form_id").attr("action", "http://我的域名/" + $(this).val());
});
纯手写,貌似没问题,实际你自己看看。就这个方法 (“$(this).val()”能不能取到值没验证!)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
from表单中加入enctype="multipart/form-data"之后,在action里面得不到其它下拉框的值

我做图片上传,在from表单中加入enctype="multipart/form-data" 这个之后,有时在action里面得不值下拉框的值,去掉那个之后就可以得到,怎么解决啊?

php 动态获取html的select的值

``` <form method="post" action=""> <select name="select"> <option value="0">请选择会员年数</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </form> <?php if(isset($_POST['select'])) { echo $_POST['select'];} ?> ``` 但是我不想用submit的按钮 那怎么写呢?

如何根据第一个下拉框中选定的值在下拉框中获取第二个值

<div class="post-text" itemprop="text"> <p>I have written the following code in PHP to generate two dropdown boxes on the same page. </p> <p>The first dropdown box gets value from a MySQL table. This dropdpwn box contains some UserIDs. The second dropdown box contains some dates which should be based on the UserID that is selected in the first dropdown box. I have filled the 2nd dropdown box with all the dates in the MySQL table, but, it should be filtered by the UserID which is selected on the first dropdown box.</p> <p>Just to inform, with these two values from these two dropdown boxes in this PHP page, I have posted them by pressing the submit button to another PHP page to process some other work.</p> <p>I would appreciate if you can help me to fill the second dropbox only based on the UserID selected on the first dropbox. Here is the code I have written to display and fill those dropdown boxes. Can you please inform me, what part of the code I should modify and I would appreciate if you can show me the modification code as well. I am a newbie in PHP, that's why I am asking for code level help.</p> <p>My code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt; Search Alert DB &lt;/title&gt; &lt;body&gt; &lt;br /&gt; &lt;?php&gt; $con = mysql_connect("localhost","root","root"); // (host, user,pwd) if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mysql", $con); echo "&lt;p&gt; Search Alert database &lt;/p&gt;"; echo "&lt;br /&gt;"; $result = mysql_query("SELECT distinct(UserID) FROM tblAlertLogSpecificUsersDayStatusFinal_1"); $options=""; echo "&lt;form action='Search_AlertDB_process.php' method='POST'&gt; "; //echo "Please choose a user: "; echo "Please choose a user: &lt;select name = userid&gt;"; echo "&lt;option&gt;-Select-"; while ($row = mysql_fetch_array($result)) { $userid=$row["UserID"]; $options ="&lt;option value = \"$userid\"&gt;$userid &lt;/option&gt;"; echo "$options"; } echo "&lt;/select&gt;"; echo "&lt;br /&gt;"; echo "&lt;br /&gt;"; $dayresult = mysql_query("SELECT distinct(Occurred_date) FROM tblAlertLogSpecificUsersDayStatusFinal_1"); $dayoptions=""; echo "Please pick a date:&lt;select name = day&gt;"; echo "&lt;option&gt;-Select-"; while ($row=mysql_fetch_array($dayresult)) { $day=$row["Occurred_date"]; $dayoptions ="&lt;option value = \"$day\"&gt;$day &lt;/option&gt;"; echo "$dayoptions"; //$options.="&lt;OPTION VALUE=\"$id\"&gt;".$day; } echo "&lt;/select&gt;"; echo "&lt;br /&gt;"; mysql_close($con); ?&gt; &lt;br /&gt; &lt;input type="submit" name="Submit" value="Search" /&gt; &lt;br /&gt; &lt;br /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </div>

如何用javascript实现:点击提交按钮把选中的《两个下拉框》的值传到指定的action中?

[code="java"] <html:form action="/listFreeWorkFlowUserAction" method="post"> <table width="96%" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td width="50%" nowrap>请选择角色: <html:select property="typeId"> <html:option value="">全部</html:option> <html:options collection="roleList" property="roleId" labelProperty="roleName" /> </html:select> 请选择部门:<html:select property="id"> <html:option value="">全部</html:option> <html:options collection="deptList" property="deptId" labelProperty="deptName" /> </html:select> <input name="pageKind" value="user" type="hidden"> <html:hidden property="currentPageNumber" value="1"/> <html:submit styleClass="button" value="查找" onclick=""/> </td> </tr> </table> </html:form> <form name="form1" action="listFreeWorkFlowUserAction.do"> ...... <% //从listFreeWorkFlowUserAction中取workFlowStepID String workFlowId = (String)request.getAttribute("workFlowId"); %> <input class="button" type="button" name="Submit" value="设置经办人" onClick="javascript:location.href='freeWorkFlowAction.do?workFlowId=<%=workFlowId%>"> </form> [/code] [color=red]我想通过<设置经办人>按钮把选中的两个下拉框值在点击按钮时传到指定的freeWorkFlowAction,请问各位大侠们怎么做?小弟急[/color]

为什么点击下一步只能判断下拉框选中值,接着就不能判断文件是否上传了?

<script> function jump() { var val = document.BulkMonitorForm.theFile.value; if(document.BulkMonitorForm.type.value=='Node') { alert('请选择类型'); return false; } if(trimAll(val)=="") { window.alert('请选择要上传的文件'); return false; } document.BulkMonitorForm.submit(); } </script> <form name="BulkMonitorForm" method="post" action="/BulkAddMonitors.do?method=uploadFile" enctype="multipart/form-data" style="display:inline;"> <select name="type" > <option value="Node" selected="selected" >--选择类型-- </option> <option value="SYSTEM" >服务器</option> </select> 要上传的文件:<input type="file" name="theFile" size="30" value=""> <input name="button1" type="button" class="buttons" value="下一步" onClick="javascript:jump()"> </form>

servlet 怎么 获取 option里面的值?????

``` <form method="post" action="${pageContext.request.contextPath}/servlet/SelectBycell?operation=selectcell"> <select name="cellphone" id="cell" align="center"> <option value="">==按省份查询==</option> <c:forEach items="${cellphone}" var="cell" varStatus="vs"> <option value="${cell}"><span align="center">${cell}</span></option> </c:forEach> </select> </form> ``` 在 servlet 中怎么获取option里面的值呢?????

似乎无法保持提交时选择的下拉值(对我来说是哑巴)

<div class="post-text" itemprop="text"> <p>I've been at this all day and my head is fried, I hope I make sense. I'm not even close to good at php or anything like it.</p> <p>I'm trying to customize a search form for worpress, it has dropdowns and the search function is working fine, I just want it to keep the value in the dropdown on submission.</p> <p>I say similar threads but I'm unable to apply it to my case.</p> <p>Your help would be much appreciated.</p> <p>Here's what I've got, sorry if it's a bit sloppy, I'm at the stage where I've lost track of what I'm doing</p> <p></p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section id="searchpropertieswidget-4" class="widget wpp_property_attributes"&gt; &lt;div class="wpp_search_properties_widget"&gt; &lt;span class="wpp_widget_no_title"&gt;&lt;/span&gt; &lt;?php if($_POST["submit"]) { $name_title = $_POST["wpp_search[property_type]"]; } ?&gt; &lt;form action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;" method="post" class="wpp_shortcode_search_form"&gt; &lt;input type="hidden" name="wpp_search[pagination]" value="off"&gt; &lt;input type="hidden" name="wpp_search[strict_search]" value="false"&gt; &lt;ul class="wpp_search_elements"&gt; &lt;li class="wpp_search_group wpp_group_not_a_group"&gt; &lt;ul class="wpp_search_group wpp_group_not_a_group"&gt; &lt;li for="wpp_search_element_4963" class="typemargin wpp_search_label wpp_search_label_property_type"&gt;Type &lt;span class="wpp_search_post_label_colon"&gt;:&lt;/span&gt; &lt;/li&gt; &lt;li class="wpp_search_form_element seach_attribute_property_type wpp_search_attribute_type_property_type "&gt; &lt;div class="wpp_search_attribute_wrap"&gt; &lt;select id="wpp_search_element_6302" class="wpp_search_select_field wpp_search_select_field_property_type property_type" name="wpp_search[property_type]"&gt; &lt;?php $names = array( '' =&gt; 'Any', 'house_rental' =&gt; 'House (rental)', 'apartment_rental' =&gt; 'Apartment (rental)', ); foreach ($names as $key =&gt; $name) { $selection = ($key === $name_title) ? 'selected="selected"' : ''; echo '\t&lt;option value="' . $key . '" ' . $selection. '&gt; ' . $name . '&lt;/option&gt;'; } ?&gt; ?&gt; &lt;/select&gt;</code></pre> </div> </div> <p>UPDATE:</p> <p>So, the code below works for keeping the dropdown selected, but I've had to rename the which means it's not connecting to the plugin to do the search.</p> <p>The reason I renamed the is that the square brackets in the name ("wpp_search[property_type]") seemed to cause $name_title = $_POST["wpp_search[property_type]"]; not to work.</p> <p>Can anyone suggest a workaround for this?</p> <p></p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?PHP $name_title = $_POST["derp"]; if($_POST["submit"]) { $name_title = $_POST["derp"]; //Check the name title that it is selected or none. if($name_title === none){ //if selected is none, add error to $errors array. $errors['name_title'] = "Please select the title of your name!"; } // sending form if(empty($errors)){ $mail_sent = wp_mail( $to, $subject, $mailBody, $headers ); } } if ($mail_sent) { ?&gt; &lt;h1 style="color: #007f00;"&gt;Request sent.&lt;/h1&gt; &lt;?php } else { ?&gt; &lt;div id="propertysearch"&gt; &lt;section id="searchpropertieswidget-4" class="widget wpp_property_attributes"&gt;&lt;div class="wpp_search_properties_widget"&gt;&lt;span class="wpp_widget_no_title"&gt;&lt;/span&gt; &lt;form id="" name="" action="&lt;?php echo get_permalink(); ?&gt;" method="post"&gt; &lt;div class="label-input-wrapper"&gt; &lt;ul class="wpp_search_elements"&gt; &lt;li&gt;&lt;div class="form-label"&gt;Title&lt;/div&gt;&lt;/li&gt; &lt;div class="form-input"&gt; &lt;li&gt;&lt;select id="wpp_search_element_6302" class="wpp_search_select_field wpp_search_select_field_property_type property_type" name="derp"&gt; &lt;?php $names = array( '' =&gt; 'Any', 'house_rental' =&gt; 'House (rental)', 'apartment_rental' =&gt; 'Apartment (rental)', ); foreach ($names as $key =&gt; $name) { $selection = ($key === $name_title) ? 'selected="selected"' : ''; echo '\t&lt;option value="' . $key . '" ' . $selection. '&gt; ' . $name . '&lt;/option&gt;'; } ?&gt; ?&gt; &lt;/select&gt; &lt;/li&gt; &lt;li class="wpp_search_form_element submit"&gt;&lt;input type="submit" class=" searchmargin wpp_search_button submit btn btn-large" value="Search"&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/section&gt; &lt;/div&gt; &lt;?php } ?&gt;</code></pre> </div> </div> </div>

提交表单后如何保持下拉菜单选择值?

<div class="post-text" itemprop="text"> <p>I am creating a very simple form with a dropdown menu and a text filed. It shows the errors if the form has empty field during the submission.</p> <p>I want to show the filled values after the form submission if there is any error. It works on text field as I expected. Ex: If fill the <code>name</code> and submit the form without filling the <code>title</code> dropdown menu, it showing the name I typed on the filed during the the error is appeared.</p> <p>But how can I do that for dropdown menu also? Ex: If I select the <code>title</code> drop down menu and submit the form without filling <code>name</code> field, it should show the selected <code>title</code> dropdown value during the the error is appeared.</p> <p>how can I do that? here is my code and it's a wordpress site:</p> <pre><code>&lt;?PHP $errors = array(); if($_POST["submit"]) { $name_title = $_POST["name_title"]; $sender = $_POST["sendername"]; //Check the name title that it is selected or none. if($name_title === none){ //if selected is none, add error to $errors array. $errors['name_title'] = "Please select the title of your name!"; } if(empty($sender)){ //Blank string, add error to $errors array. $errors['sendername'] = "Please enter your name!"; } // sending form if(empty($errors)){ $mail_sent = wp_mail( $to, $subject, $mailBody, $headers ); } } if ($mail_sent) { ?&gt; &lt;h1 style="color: #007f00;"&gt;Request sent.&lt;/h1&gt; &lt;?php } else { ?&gt; &lt;form id="" name="" action="&lt;?php echo get_permalink(); ?&gt;" method="post"&gt; &lt;div class="label-input-wrapper"&gt; &lt;div class="form-label"&gt;Title&lt;/div&gt; &lt;div class="form-input"&gt; &lt;select name="name_title" class="name-title-input"&gt; &lt;option value="none" selected="selected"&gt;Select Title&lt;/option&gt; &lt;option value="Mr"&gt;Mr&lt;/option&gt; &lt;option value="Mrs"&gt;Mrs&lt;/option&gt; &lt;option value="Miss"&gt;Miss&lt;/option&gt; &lt;option value="4"&gt;Ms&lt;/option&gt; &lt;/select&gt; &lt;div class="error-msg"&gt; &lt;?php if(isset($errors['name_title'])) { echo '&lt;span style="color: red"&gt;'.$errors['name_title'].'&lt;/span&gt;'; } ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="label-input-wrapper"&gt; &lt;div class="form-label"&gt;Name&lt;/div&gt; &lt;div class="form-input"&gt; &lt;input type="text" name="sendername" value="&lt;?PHP if(!empty($errors)) { echo $sender;} ?&gt;" /&gt; &lt;div class="error-msg"&gt; &lt;?php if(isset($errors['sendername'])) { echo '&lt;span style="color: red"&gt;'.$errors['sendername'].'&lt;/span&gt;'; } ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;input type="submit" value="Submit" name="submit"&gt; &lt;/form&gt; &lt;?php } ?&gt; </code></pre> </div>

获取选定的下拉值 - PHP

<div class="post-text" itemprop="text"> <p>I have a dropdown populated with values I get from the database. I need to perform some queries based on the selected option, but first I need to save the selected value on a new variable.</p> <p>This is my dropdown:</p> <pre><code>&lt;form name="dashboard_form" action="" id="dashboard_form" method="post"&gt; &lt;tr&gt; &lt;td&gt;&lt;?php _e('Select City')?&gt;:&lt;/td&gt; &lt;td&gt; &lt;select class="selected_city" name="selected_city" style="margin: 20px;width:300px;" required&gt; &lt;?php foreach ( $all_cities as $city ) { echo '&lt;option value='.$city-&gt;ID.'&gt;'.$city-&gt;name.'&lt;/option&gt;'; } ?&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/form&gt; </code></pre> <p>*$all_cities is an array with all the cities.</p> <p>My jQuery:</p> <pre><code>&lt;script&gt; jQuery("#dashboard_form").validate({ ignore:'', rules: { 'selected_city': { required: true }}, messages: { 'selected_city': "Please Select a City", }, errorPlacement: function(error, element) { jQuery(element).closest('tr').next().find('.error_label').html(error); } }); &lt;/script&gt; </code></pre> <p>How can I save on a $new_variable my selected value from the dropdown?</p> <p>EDIT 1:</p> <p>I added the following to </p> <pre><code>$(document).ready(function () { var selected_city; $('.selected_city').change(function() { selected_city = $(this).val(); alert(selected_city); }); }); </code></pre> <p>The alert(selected_city) prints the correct city, how can I use this selected_city on the PHP?</p> <p>EDIT2: The problem is the dropdown is not submitting anything, so I created a Button to force it to Submit:</p> <pre><code> &lt;input type="submit" value="&lt;?php _e('Send Now')?&gt;" name="send_now_button" id="send_now_button" class="button button-primary"&gt; </code></pre> <p>Then:</p> <pre><code>if(isset($_POST['send_now_button'])){ if(isset($_POST['selected_city'])) { $selected_city = $_POST['selected_city']; } else {$selected_city = 'Lisboa'; } } </code></pre> <p>Now when I echo $selected_cities_id; it gives the correct value!</p> </div>

从php中的select / option标签中提取值?

<div class="post-text" itemprop="text"> <p>I am not exactly how to do it and how to word the question, so i shall try my best (PS: i'm new to web dev, so please be clear in your answers if you could).</p> <p>So, I have got a drop down menu with the list names, which are taken from my database. In that database i have a table with names column (the ones that are rendered to the dropdown box) and relevant information to those names. Now, I want that relevant information to appear below in a tag when a user choose one of those names. I also cannot use the form.submit() method because my submit button is already taken for something else.</p> <p>Here is the code to that bit:</p> <pre><code>&lt;form name="name_choice" method="post" action="index.php"&gt; &lt;select name="names" onchange="form.some_method()"&gt; &lt;option value="NULL" selected="selected"&gt;--Select name--&lt;/option&gt; &lt;?php for ( $i = 0; $i &lt; $numrows; $i++ ) { //for all the columns, iterate and print out $id_names = mysql_result($result, $i); echo "&lt;option value='".$id_names."'&gt;".$id_names."&lt;/option&gt;"; } ?&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> <p>So the bit above works fine, but the "some_method()" is my problem, i don't know what to trigger to display the text in the div below the drop down box (code is below for it):</p> <pre><code>&lt;div class="information"&gt; &lt;!--if the name is chosen ONLY!--&gt; &lt;?php if($_POST['names'] == "NULL") { echo '&lt;p&gt;Please select an option from the select box.&lt;/p&gt;'; //this bit is for testing } else { echo '&lt;p&gt;You have selected: &lt;strong&gt;', $_POST['names'], '&lt;/strong&gt;.&lt;/p&gt;'; //and then how to echo the relevant information?:( } ?&gt; &lt;/div&gt;&lt;!--end of possible info--&gt; </code></pre> </div>

如何使用下拉框中的值填充表格?

<div class="post-text" itemprop="text"> <p>I have three tables and two dropdown boxes. I have populated two of the tables and entered their values into the dropdown boxes. Now, I would like to choose a value from both of the dropdown boxes and put their values into the third dropdown box.</p> <pre><code> &lt;fieldset&gt; &lt;legend&gt;New Cast&lt;/legend&gt; &lt;table&gt; &lt;form action="04castdb.php" method="post"&gt; &lt;/fieldset&gt; &lt;?php $query = "select * from dbhx_movie"; $result = mysql_query($query); if(!$result) { die("query failed"); } echo "&lt;select name='movie'&gt;"; while($row = mysql_fetch_array($result)) { echo "&lt;option value='$row[pk]'&gt;$row[name]&lt;/option&gt;"; } echo "&lt;/select&gt;movie&lt;/br&gt;"; echo "&lt;select name='actor'&gt;"; $query = "select * from dbhx_actor"; $result = mysql_query($query); if(!$result) { die("query failed"); } while($row = mysql_fetch_array($result)) { echo "&lt;option value='$row[pk]'&gt;$row[surname]&lt;/option&gt;"; } echo "&lt;/select&gt;actor&lt;/br&gt;"; echo "&lt;input type='submit' value='swag'/&gt;"; ?&gt; &lt;/table&gt; &lt;/fieldset&gt; </code></pre> <p>This is the code I have used to populate the dropdown boxes. But when I press submit, it doesn't enter the data from the chosen values. Can anyone make some sense of it?</p> </div>

如何从下拉列表中获取所选值

<div class="post-text" itemprop="text"> <p>I am trying to use a dynamically generated dropdown list to populate a table. I have a drop down list that is generated from my database (it grabs all the years available for a specific player). I want to be able to select a year from the dropdown and have it update my table. I have the dropdown being generated, but I am not able to get the selected value from the dropdown. I have code below that I found here, but it doesn't seem to work. Here is the code I have so far:</p> <pre><code>&lt;input name="update" type="submit" value="Update" /&gt; &lt;/form&gt; &lt;p&gt;&lt;/p&gt; &lt;form action="player_login.html"&gt; &lt;input type="submit" value="Logout" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;div style="float: left"&gt; &lt;p&gt;&lt;/p&gt; &lt;h1&gt;Player Stats&lt;/h1&gt; &lt;table width="300" border="1" cellpadding="2" cellspacing="2"&gt; &lt;?php // get "id" field from player table $login_id = $_COOKIE["DB"]; $id = "select id from player where login_id='$login_id';"; $result1=mysql_query($id) or die('Select1 Query failed: ' . mysql_error()); $row = mysql_fetch_array($result1); // create a dropdown from stats table in db echo "--Select Year--"; $years_query = "select year from stats where player_id='$row[id]';"; $years = mysql_query($years_query, $connect); // fill array with db info $var = array(); while ($row2 = mysql_fetch_array($years)) { $var[] = $row2['year']; } // create dropdown echo'&lt;select name="years" id="years"&gt;'; // For each value of the array assign variable name "city" foreach($var as $year) { echo'&lt;option value="'.$year.'"&gt;'.$year.'&lt;/option&gt;'; } echo'&lt;/select&gt;'; // get selected option from dropdown $selected_key = $_POST['years']; $selected_val = $var[$_POST['years']]; echo "&lt;p&gt;&lt;/p&gt;selected key: " . $selected_val; // this wont print anything??? $search_query="select * from stats where player_id='$row[id]' and year=2013;"; $result=mysql_query($search_query) or die('Select2 Query failed: ' . mysql_error()); $num_cols = mysql_num_fields($result); $line = mysql_fetch_row($result); // create table with results echo "&lt;tr&gt;"; echo "&lt;td&gt;Year&lt;/td&gt;"; $j=1; echo "&lt;td&gt;&lt;input name='$j' type='text' value='$line[$j]' size=20/&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; echo "&lt;tr&gt;"; echo "&lt;td&gt;Total Points&lt;/td&gt;"; $j=2; echo "&lt;td&gt;&lt;input name='$j' type='text' value='$line[$j]' size=20/&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; echo "&lt;tr&gt;"; echo "&lt;td&gt;PPG&lt;/td&gt;"; $j=3; echo "&lt;td&gt;&lt;input name='$j' type='text' value='$line[$j]' size=20/&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; ?&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> </div>

jsp获取二级联动下拉列表的两个值 表单

1 ``` <html> <head> <title>This is a test!</title> </head> <body> <form name="frm" action="demo1.jsp"> <select name="s1" onChange="redirec(document.frm.s1.options.selectedIndex)"> <option selected>请选择</option> <option value="脚本语言">脚本语言</option> <option value="高级语言">高级语言</option> <option value="其他语言">其他语言</option> </select> <select name="s2"> <option selected>请选择</option> </select> <input type="submit"> </form> <script language="javascript" > //获取一级菜单长度 var select1_len = document.frm.s1.options.length; var select2 = new Array(select1_len); //把一级菜单都设为数组 for (i=0; i<select1_len; i++) { select2[i] = new Array();} //定义基本选项 select2[0][0] = new Option("请选择", " "); select2[1][0] = new Option("PHP", " "); select2[1][1] = new Option("ASP", " "); select2[1][2] = new Option("JSP", " "); select2[2][0] = new Option("C/C++", " "); select2[2][1] = new Option("Java", " "); select2[2][2] = new Option("C#", " "); select2[3][0] = new Option("Perl", " "); select2[3][1] = new Option("Ruby", " "); select2[3][2] = new Option("Python", " "); //联动函数 function redirec(x) { var temp = document.frm.s2; for (i=0;i<select2[x].length;i++) { temp.options[ i]=new Option(select2[x][i].text,select2[x][i].value);} temp.options[0].selected=true; } </script> </body> </html> ```

select多选下拉全选问题

开发后台的是时候用到多选下拉列表,但下拉列表的项要全选才能提交数据,于是再点保存按钮的时候加两个jq全选下拉列表项,不动下拉列表的时候没有问题,,点保存就会全选下拉列表,但如果手动选择了下拉列表中的其中一项,或者删除其中一项,点保存就没法全选下拉列表,不知道是什么问题,求大神帮看一下,下面是部分代码 ``` <form action="?action=save" method="post" id="myform" name="myform" enctype="multipart/form-data"> <select multiple="multiple" name="duotu[]" class="common-select-multiple" id="duotu"> <option value="/uploads/image/20190717/20190717064658_56532.jpg">/uploads/image/20190717/20190717064658_56532.jpg</option> <option value="/uploads/image/20190717/20190717064658_22694.jpg">/uploads/image/20190717/20190717064658_22694.jpg</option> <option value="/uploads/image/20190717/20190717064658_35757.jpg">/uploads/image/20190717/20190717064658_35757.jpg</option> <option value="/uploads/image/20190717/20190717064658_95940.jpg">/uploads/image/20190717/20190717064658_95940.jpg</option> </select> <input id="savebutton" class="botton-common" value="保存" type="submit"> </form> <script type="text/javascript"> $(function() { //保存时全选 $("#savebutton").click(function(){ $("#duotu option").attr("selected","selected"); }); }); </script> ```

获得table某个单元格的内容,然后将select中等于该内容的项,变为选中项。

var tds=$('#infor tr:eq(1) td:nth-child(7)').html(); $("#seachContinent").find("option[text='"+tds+"']").attr("selected",true); tds可以获得内容,第二行中的tds若写死为“非洲”也是好用的,但是上面的这样写就不好用,请问问题出在哪里?

html dom使用已经获取的变量的不到下拉列表的选中项的索引

<DOCTYPE html> <html> <head><title>练习</title></head> <style type="text/css" > .f1{font-size:10px;} </style> <script type="text/javascript"> window.onload = function(){ var form = document.getElementById("firstForm"); var opts = form.subjects.options; var info = form.info; form.subjects.onchange = function(){ var form = document.getElementById("firstForm"); info.value = `this.selectedIndex` +"" + opts[0].text; // 如果是使用form的话,得到undefined;使用this缺可以 } } </script> <body style="margin-left:20px;margin-top:20px;"> <form action="#" target="_self" id="firstForm" method="POST"> <select name="subjects" size="12"> <optgroup label="基础课程"> <option value="datamining" selected="true">数据挖掘</option> <option value="clustering">聚类</option> <option value="classify">分类</option> </optgroup> <optgroup label="必修课程"> <option value="java">JAVA</option> <option value="cpp">c++</option> </optgroup> <optgroup label="选修课程"> <option value="cars">汽车艺术</option> <option value="movies">电影鉴赏</option> </optgroup> </select></br> <textarea name="info" rows="12" cols="100"></textarea><br/> </form> </body> </html> 对于this.selectedIndex部分,如果使用已经获取到的form变量,得不到选中项的索引;使用this却可以,不知道为什么?

jsp修改的时候下拉框怎么取修改数据的值?

[code="ruby"]<%@ page pageEncoding="UTF-8"%> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> <html> <head> <link rel="stylesheet" href="css/userQuery.css" type="text/css" /> <title><bean:message key="updatePageLayout"/></title> <script type='text/javascript' src='<%request.getContextPath();%>tabs/tabs.js'> </script> <script type='text/javascript' src='<%request.getContextPath();%>dwr/engine.js'> </script> <script type='text/javascript' src='<%request.getContextPath();%>dwr/util.js'> </script> <script type='text/javascript' src='<%request.getContextPath();%>dwr/interface/DWRUser.js'> </script> <script type="text/javascript" src='<%request.getContextPath();%>js/user.js'> </script> <script type='text/javascript' src='<%request.getContextPath();%>js/classes.js'> </script> <script type="text/javascript" src='<%request.getContextPath();%>js/team.js'> </script> <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/DWRClasses.js'></script> <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/DWRTeam.js'></script> </head> <body onload="getClassesMap();"> <table> <html:form action="update.do?method=update" onsubmit="validateUserForm(this);"> <html:javascript formName="UserForm" /> <tr><td><html:hidden property="id" value="${UserForm.id}"/></td></tr> <tr> <td> <bean:message key="user.login"/> <html:text property="loginName" styleId="name" value="${UserForm.loginName}" readonly="true"/> <font id="failure" color="Red" style="display: none;"> <bean:message key="user.loginRepetition"/></font> <font id="success" color="Green" style="display: none;"> <bean:message key="user.loginRight"/></font> </td></tr> <tr><td> <bean:message key="user.password"/> <html:password property="password" styleId="password" onchange="check();" value="${UserForm.password}"/> </td></tr> <tr><td> <bean:message key="user.confirmPassword"/> <html:password property="password" styleId="validatePassword" onchange="checkPassword();" value="${UserForm.password}"/> </td></tr> <tr><td> <bean:message key="user.name"/> <html:text property="realName" value="${UserForm.realName}"/> </td></tr> <tr><td> <bean:message key="user.sex" /> <bean:message key="user.boy"/> <html:radio property="sex" value="男" /> <bean:message key="user.girl"/> <html:radio property="sex" value="女" /> </td></tr> <tr><td> <bean:message key="user.age"/> <html:text property="age" value="${UserForm.age}"/> </td></tr> <tr><td> <bean:message key="user.email" /> <html:text property="email" value="${UserForm.email}"/> </td></tr> <tr><td> <bean:message key="user.classes"/> <html:select property="classesId" styleId="classes" onchange="getTeamByClassesId(this.value);" /> </td></tr> <tr><td> <bean:message key="user.team"/> <html:select property="teamId" styleId="teamId" > <html:option value="">-Choice-</html:option> </html:select> </td></tr> <tr> <td> <center><html:submit onclick="submitForm()" > <bean:message key="submission"/> </html:submit> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <html:reset > <bean:message key="reset"/> </html:reset> </center> </td></tr> </html:form> </table> </body> </html>[/code] 修改的页面用select怎么拿到他默认的修改的值?刚刚学这东东,希望多多指教!

如何在PHP中的动态下拉列表中显示选定的值

<div class="post-text" itemprop="text"> <p>I am trying to retain the value selected in a drop down menu. Everything is working, but I don't know how to show and retain the selected value. How can I do this?</p> <p>I've got this working using another way: </p> <pre><code>&lt;?php if($_POST['selClass'] == $row1['class']) echo 'selected="selected"' ?&gt; </code></pre> <p>but this leads to other problems, i.e. a blank option in my drop down menu.</p> <pre><code>&lt;form action="" method="POST" name="form1" id="form1"&gt; &lt;select name="selClass" size="1" id="selClass" onchange="form1.submit()"&gt; &lt;option value=""&gt;Select a class&lt;/option&gt; &lt;?php echo "&lt;option value='". "All records". "' . &gt;" . "all records". "&lt;/option&gt;"; while ($row1 = mysqli_fetch_array($rs5)) { echo "&lt;option value='".$row1["class"] ."'&gt;" . $row1["class"]. "&lt;/option&gt;"; } ?&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> </div>

struts2 select标签获取action的集合属性值 动态生成下拉菜单 报错

<pre name="code" class="java">   1.要获取集合list的Action类</pre> <pre name="code" class="java">public class RoleAction extends ActionSupport { private Role role; public RoleService roleService; public String message; public List list; public static ActionContext ac = null; public String getMessage() { return message; } @Resource(name = "roleService") public void setRoleService(RoleService roleService) { this.roleService = roleService; } public List getList() { return list; } public Role getRole() { return role; } public void setRole(Role role) { this.role = role; } public String List() throws Exception { /* * 浏览权限 */ if (this.isRole()) { this.list = this.roleService.get(); System.out.println(this.getList()); return "list"; } else return ERROR; } }</pre> <pre name="code" class="java">2.struts.xml配置action</pre> <pre name="code" class="java"><pre name="code" class="java"> &lt;action name="nuserAction_*" class="nuserAction" method="{1}"&gt; &lt;interceptor-ref name="nuserInterceptorStack"&gt;&lt;/interceptor-ref&gt; &lt;result name="list"&gt;/user/ListUser.jsp&lt;/result&gt; &lt;result name="loginSuccess"&gt;main.jsp&lt;/result&gt; &lt;/action&gt; &lt;action name="roleAction_*" class="roleAction" method="{1}"&gt; &lt;result name="list"&gt;/role/ListRole.jsp&lt;/result&gt; &lt;/action&gt;</pre> </pre> <pre name="code" class="java">3.adduser.jsp中代码如下:</pre> <pre name="code" class="java"><pre name="code" class="java">&lt;s:form action="nuserAction_Add" method="post"&gt; &lt;s:action name="roleAction_List" id="role"&gt;&lt;/s:action&gt; &lt;s:select list="#role.list" label="权限" name="nuser.role.id" headerKey="-1" headerValue="--请选择--" listKey="id" listValue="position"&gt;&lt;/s:select&gt; &lt;s:textfield name="nuser.name" label="用户名" value=""&gt;&lt;/s:textfield&gt; &lt;s:password name="nuser.password" label="密码" value=""&gt;&lt;/s:password&gt; &lt;s:submit value="提交"&gt;&lt;/s:submit&gt; &lt;s:reset value="重置"&gt;&lt;/s:reset&gt; &lt;/s:form&gt;</pre> 此处通过action标签 先执行roleAction_List 来获取 属性list值 然后赋给select标签的list属性 来生成下拉菜单。</pre> <pre name="code" class="java">有时候能够正常显示 但是有时又会报错 异常如下:</pre> <pre name="code" class="java"><pre name="code" class="java">严重: Servlet.service() for servlet jsp threw exception tag 'select', field 'list', name 'nuser.role.id': The requested list key '#role.list' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] at org.apache.struts2.components.Component.fieldError(Component.java:237)</pre> </pre> <pre name="code" class="java">不知道什么情况 请各位帮忙看看!</pre>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

都前后端分离了,咱就别做页面跳转了!统统 JSON 交互

文章目录1. 无状态登录1.1 什么是有状态1.2 什么是无状态1.3 如何实现无状态1.4 各自优缺点2. 登录交互2.1 前后端分离的数据交互2.2 登录成功2.3 登录失败3. 未认证处理方案4. 注销登录 这是本系列的第四篇,有小伙伴找不到之前文章,松哥给大家列一个索引出来: 挖一个大坑,Spring Security 开搞! 松哥手把手带你入门 Spring Security,别再问密...

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

阿里面试官让我用Zk(Zookeeper)实现分布式锁

他可能没想到,我当场手写出来了

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

立即提问
相关内容推荐