怎么往数据库里添加select标签中的optionoption里的的id

09-1709-0909-0909-13
02-2211-0101-1303-12
◇本站云标签输入关键字或相关内容进行搜索
&p style=&height:30&&
&label&&/label&
&select style=&width:90%;font-size:12margin-top:-20& id=&select& onchange=&window.location=this.value&&
&option&本人(男,35岁,张三)&/option&
&option value=&2&&父母(男,35岁,张三)&/option&
&option value=&3&&爱人(男,35岁,张三)&/option&
&option value=&4&&子女(男,35岁,张三)&/option&
&option value=&4&&朋友(男,35岁,张三)&/option&
&option value=&https:www.baidu.com&&&/option&
前几项都可以选中,在页面中显示,最后一项要跳转
赞助DCloud可免广告,
挺有趣的,帮你想了一下&select style=&width:90%;font-size:12margin-top:-20& id=&select& onchange=&!this.value.match(/^https:www.[a-zA-Z]+.com$/g)?false:(window.location=this.value)&&&option&本人(男,35岁,张三)&/option&&option value=&2&&父母(男,35岁,张三)&/option&&option value=&3&&爱人(男,35岁,张三)&/option&&option value=&4&&子女(男,35岁,张三)&/option&&option value=&4&&朋友(男,35岁,张三)&/option&&option value=&https:www.baidu.com&&百度&/option&&/select&
谢谢啦,这个问题我换了个写法解决啦
要回复问题请先或
最新活动: 1 天前
赞助DCloud可免广告,
赞助DCloud可免广告,HTML中的&select&标签如何设置默认选中的选项 - 简书
HTML中的&select&标签如何设置默认选中的选项
1、通过select的属性来设置选中项,此方法可以在动态语言如php后台根据需要控制输出结果
&select name="" id="sel"&
&option value="1"&1&/option&
&option value="2" selected="selected"&2&/option&
&!-- 默认选中第二项 --&
&option value="3"&3&/option&
2、通过前端js来控制选中项
function change(){
document.getElementById('sel')[2].selected=
&select name="" id="sel"&
&option value="1"&1&/option&
&option value="2" selected="selected"&2&/option&
&option value="3"&3&/option&
&input type="button" value="修改" onclick="change()"/&
3、获取&select&标签选中项文本的js代码
var val = document.all.Item.option[document.all.Item.selectedIndex].
var i = document.getElementById('sel').options[document.getElementById('sel').selected].
select标签的一些其他操作技巧
1)动态创建select
createSelect(){
mySelect = document.createElement( "select" );
mySelect.id =
"mySelect" ;
document.body.appendChild(mySelect);
2)添加选项option
addOption(){
//根据id查找对象,
obj=document.getElementById( 'mySelect' );
/ /添加一个选项
obj.add( new
Option( "文本" , "值" ));
3)删除所有选项option
removeAll(){
obj=document.getElementById( 'mySelect' );
obj.options.length=0;
4)删除一个选项option
removeOne(){
obj=document.getElementById( 'mySelect' );
//index,要删除选项的序号,这里取当前选中选项的
index=obj.selectedI
obj.options.remove(index);
5)获得选项option的值
obj=document.getElementById( 'mySelect' );
index=obj.selectedI
//序号,取当前选中选
val = obj.options[index].
6)获得选项option的文本
obj=document.getElementById( 'mySelect' );
index=obj.selectedI
//序号,取当前选中选项的序号
val = obj.options[index].
7)修改选项option
obj=document.getElementById( 'mySelect' );
index=obj.selectedI
//序号,取当前选中选项的序号
val = obj.options[index]= new
Option( "新文本" , "新值" )
8)删除select
removeSelect(){
mySelect = document.getElementById( "mySelect" );
mySelect.parentNode.removeChild(mySelect);
本人做php的,最近发现JS真的是博大精深啊,比PHP难.在HTML中,表单是由form元素来表示的,但是在javascript中,表单则由HTMLFormElement类型,此元素继承了HTMLElement,因此与其他HTML元素具有相同的默认属性;HTMLFormEl...
《ijs》速成开发手册3.0 官方用户交流:iApp开发交流(1) iApp开发交流(2) iApp开发交流(3) iApp开发交流(4) iApp开发交流(5) iApp游戏开发交流...
百战程序员_ Java1573题 QQ群:034603 掌握80%年薪20万掌握50%年薪10万 全程项目穿插, 从易到难,含17个项目视频和资料持续更新,请关注www.itbaizhan.com 国内最牛七星级团队马士兵、高淇等11位十年开发经验专...
jQuery获取Select选择的Text和Value: 语法解释: 1. $(&#select_id&).change(function(){//code...}); //为Select添加事件,当选择其中一项时触发 2. var checkText=$(&#select...
1:使用SHOW语句找出在服务器上当前存在什么数据库: mysql& SHOW DATABASES; 2:2、创建一个数据库MYSQLDATA mysql& CREATE DATABASE MYSQLDATA; 3:选择你所创建的数据库 mysql& USE MYSQLDA...
他是个搞设计的工程师,她是中学毕业班的班任老师,两人都错过了恋爱的最佳季节,后来经人介绍而相识。没有惊天动地的过程,平平淡淡地相处,自自然然地结婚。 婚后第三天,他就跑到单位加班,为了赶设计,他甚至可以彻夜拼命,连续几天几夜不回家。她忙于毕业班的管理,经常晚归。为了...
一个人 不要争辩什么 会伤害很多人 刀子般的嘴 根本没有一块豆腐嫩的心 女人友情提示了 而中国男人 悲催的 无法用诗歌般的宣言 去面对每一次生活!
着一顶破布做的毡帽, 着一身稻草做的衣裳, 撑一根长长的竹篙, 稻草人,伫立成一个姿势守望! 它们驻守着成功的果实, 驻守着庄稼人的甜蜜美梦。 看,一望无际的视野,良田万亩, 微风吹过,金色的地毯涌动着窃喜! 金黄的稻穗沉甸甸的摩肩接踵, 丰硕的高粱像大姑娘般垂着胸, 大豆...
“谁的青春不迷茫” 很多时候都觉得这句话简直不能更准确,就比如现在,秋日午后本该惬意但现在却不知所措的一个迷茫时刻 半卧在沙发上看微微看到兴起,突然手机一个卡顿,心里咒骂着这破手机怎么隔两天就给我来个故障,屏幕上却显示接进来一个电话.. 校园小号,大概是舍友的吧 “喂,Q,...&html:select&&html:optionsCollection&中怎么取得数据库中对应值? - ITeye问答
我在jsp页面中用了:
&html:select property="custLevelLabel" value="${customer.custLevelLabel}" size="1"&
&html:optionsCollection name="level" label="dictItem" value="dictId"/&
&/html:select&
用于取得数据库中数据库中数据,这点已经实现,已经把一列值取出并放入下拉列表。
这是一个编辑页面,也就是从一个列表页面跳转到这个页面(编辑页面代码如下):
&%@ page language="java" pageEncoding="UTF-8"%&
&%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %&
&%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %&
&%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %&
&%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %&
&!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&
&html:html lang="true"&
& &head&
&&& &html:base /&
&&&
&&& &title&客户信息&/title&
&meta http-equiv="pragma" content="no-cache"&
&meta http-equiv="cache-control" content="no-cache"&
&meta http-equiv="expires" content="0"&&&&
&meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&
&meta http-equiv="description" content="This is my page"&
&link rel="stylesheet" type="text/css" href="styles.css"&
& &script type="text/javascript" src="../../../scripts/js/common.js"&&/script&
& &link rel="stylesheet" href="../../../styles/css/style.css" type="text/css"&&/link&
& &script type="text/javascript"&
&
function showMessage(){
&
var msg=document.getElementById("lnkmsg").
&
showMsg(msg);&
}
& &/script&
& &/head&
&
& &body onload="showMessage();"&
&&& &div class="page_title"&客户信息管理 & 客户信息&/div&
&&& &html:form action="/updatecustomer.do?id=${custId}" method="post"&
&div class="button_bar"&
&html:button property="" styleClass="common_button" onclick="help('');"&帮助&/html:button&
&html:button property="" styleClass="common_button" onclick="to('linkman.do?id=${custId}');"&联系人&/html:button&
&html:button property="" styleClass="common_button" onclick="to('activity.do?id=${custId}');"&交往记录&/html:button&
&html:button property="" styleClass="common_button" onclick="to('orders.do?id=${custId}');"&历史订单&/html:button&
&html:button property="" styleClass="common_button" onclick="back();"&返回&/html:button&
&html:submit property="submit" styleClass="common_button"&保存&/html:submit&
&logic:present name="customer"&
&table class="query_form_table"&
&th&客户编号&/th&
&td&${customer.custNo}&/td&
&th&名称&/th&
&td&&html:text property="custName" value="${customer.custName}"&&/html:text&&span class="red_star"&&/span&&/td&
&th&地区&/th&
&html:select property="custRegion" value="${customer.custRegion}"&
&html:optionsCollection name="region" label="dictItem" value="dictId"/&
&/html:select&
&th&客户经理&/th&
&html:select property="custManagerName" value="${customer.custManagerName}" size="1"&
&html:optionsCollection name="mamager" label="usrName" value="usrId"/&
&/html:select&
&th&客户等级&/th&
&html:select property="custLevelLabel" value="${customer.custLevelLabel}" size="1"&
&html:optionsCollection name="level" label="dictItem" value="dictId"/&
&/html:select&
&th&客户满意度&/th&
&html:select styleId="Satisfy" property="custSatisfy" size="1"&
&html:option value="0"&未指定&/html:option&
&html:option value="5"&☆☆☆☆☆&/html:option&
&html:option value="4"&☆☆☆☆&/html:option&
&html:option value="3"&☆☆☆&/html:option&
&html:option value="2"&☆☆&/html:option&
&html:option value="1"&☆&/html:option&
&/html:select&
&th&客户信用度&/th&
&html:select styleId="Credit" property="custCredit" size="1"&
&html:option value="0"&未指定&/html:option&
&html:option value="5"&☆☆☆☆☆&/html:option&
&html:option value="4"&☆☆☆☆&/html:option&
&html:option value="3"&☆☆☆&/html:option&
&html:option value="2"&☆☆&/html:option&
&html:option value="1"&☆&/html:option&
&/html:select&
&table class="query_form_table" id="table1"&
&th&地址&/th&
&td&&html:text property="custAddr" value="${customer.custAddr}"&&/html:text&&span class="red_star"&*&/span&&/td&
&th&邮政编码&/th&
&td&&html:text property="custZip" value="${customer.custZip}"&&/html:text&&span class="red_star"&*&/span&&/td&
&th&电话&/th&
&td&&html:text property="custTel" value="${customer.custTel}"&&/html:text&&span class="red_star"&*&/span&&/td&
&th&传真&/th&
&td&&html:text property="custFax" value="${customer.custFax}"&&/html:text&&span class="red_star"&*&/span&&/td&
&th&网址&/th&
&td&&html:text property="custWebsite" value="${customer.custWebsite}"&&/html:text&&span class="red_star"&*&/span&&/td&
&table class="query_form_table" id="table2"&
&th&营业执照注册号&/th&
&td&&html:text property="custLicenceNo" value="${customer.custLicenceNo}"&&/html:text&&/td&
&th&法人&/th&
&td&&html:text property="custChieftain" value="${customer.custChieftain}"&&/html:text&&span class="red_star"&*&/span&
&th&注册资金(万元)&/th&
&html:text property="custBankroll" value="${customer.custBankroll}"&&/html:text& &/td&
&th&年营业额&/th&
&html:text property="custTurnover" value="${customer.custTurnover}"&&/html:text&
&th&开户银行&/th&
&html:text property="custBank" value="${customer.custBank}"&&/html:text&&span class="red_star"&*&/span&
&th&银行帐号&/th&
&td&&html:text property="custBankaccount" value="${customer.custBankAccount}"&&/html:text&&span class="red_star"&*&/span&&/td&
&th&地税登记号&/th&
&html:text property="custLocaltaxno" value="${customer.custLocalTaxNo}"&&/html:text&&/td&
&th&国税登记号&/th&
&td&&html:text property="custNationaltaxno" value="${customer.custNationalTaxNo}"&&/html:text&&/td&
&/logic:present&
&/html:form&
&input type="hidden" id="lnkmsg" value="${msg}"&
& &/body&
&/html:html&
其他的内容都能够从数据库读出,并正确显示,但就是那几个下拉列表不知如何让它选中数据库原有的对应值
请哪位高手解决一下,小弟万分感激。
&html:select property="custManagerName" &
&html:optionsCollection property="lable名称"/&
&/html:select&
没那么复杂 像上面就行了 只要在跳转到这个页面前对应的select属性值和lable已经塞到页面上就会正常显示的
&html:select/&这个标签不需要指定value的值,只要你的property与你bean中响应的值对应即可,如果bean里对象中有值,他会自动填充;另外,el的标签需要指定struts-config的beanName,如果不用,你可以写成如下的样子:
&html:select property="customer.custRegion"&
&html:optionsCollection name="region" label="dictItem" value="dictId"/&
&/html:select&
&html:select property="customer.custManagerName" size="1"&
&html:optionsCollection name="mamager" label="usrName" value="usrId"/&
&/html:select&
&html:select property="customer.custLevelLabel" size="1"&
&html:optionsCollection name="level" label="dictItem" value="dictId"/&
&/html:select&
&html:select styleId="Satisfy" property="customer.custSatisfy" size="1"&
&html:option value="0"&未指定&/html:option&
&html:option value="5"&☆☆☆☆☆&/html:option&
&html:option value="4"&☆☆☆☆&/html:option&
&html:option value="3"&☆☆☆&/html:option&
&html:option value="2"&☆☆&/html:option&
&html:option value="1"&☆&/html:option&
&/html:select&
下面的那个类似
&html:select proerpty=""&
&html:optionsCollection name="集合" label="显示" value="值(ID)"/&
&/html:select&
&html:select property=""&
property 这个值要和你action里面的form对象对应啊。
比如 customer.custLevelLabel 而不是 custLevelLabel
已解决问题
未解决问题没有更多推荐了,
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!}

我要回帖

更多关于 select option a标签 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信