用Javascript获取select的值

 <script type="text/javascript">
 function GetValue()
 {
  var strUrl;  
  strUrl=window.document.getElementById("friendLink").value;
  
  window.open("http://22+strurl/);  
   
 }
</script>

 

//根据链接类型读取数据库中的数据

        public static string GetLink(string type)
        {
            string sqlTemp = "select * from shang_cms_friends where lianjie_pic ='" + type + "'";
            DataSet ds = SQLHelper.DataAdapter(sqlTemp, SQLHelper.SDACmd.select, "sqlIndex");

            string link = null;
            string strSelectStart = "<select id=friendLink name=friendLink style=width:275px;height:27px; onChange=javascript:GetValue(); >";
            if (type == "0")
            {
                link = strSelectStart + "<option selected=selected>--------友情链接--------</option>";
            }
            else
            {
                link = strSelectStart + "<option selected=selected>--------子公司链接--------</option>";
            }

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {

                link += "<option value="+ds.Tables[0].Rows[i]["lianjie_url"].ToString()+">" + ds.Tables[0].Rows[i]["lianjie_name"].ToString() + "</option>";
            }

            link += "</select>";

            return link;

           // <select id="friendLink" name="friendLink" style="width: 275px; height: 27px;">
             //       <option selected="selected">--------友情链接--------</option>
             //   </select>
        }

posted @ 2009-07-09 15:31  yangan-wu2008  阅读(1988)  评论(0编辑  收藏  举报