台灣最大程式設計社群網站
線上人數
1060
 
會員總數:246136
討論主題:189720
歡迎您免費加入會員
討論區列表 >> Java Script/ Node.js >> 連動式的下拉式選單
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
連動式的下拉式選單
價值 : 50 QP  點閱數:1907 回應數:0
樓主


門外漢
0 34
452 54
發送站內信

下面這段程式碼是前人已開發好的網頁,
中間有三個下拉式選單,用IE開啟都很正常,
下拉式選單本來是第一個選擇以後,第二個才會有資料可以選擇,接著第三個也是一樣
但是最近發現,沒辦法在手機的瀏覽器上正常執行,用電腦的其他瀏覽器才發現也沒辦法在chrome及firefox上正常瀏覽
因為我不懂javascript,所以把那一整段相關的網頁原始碼po上來了,想請教一下式哪裡出了問題,有沒有什麼方式可以改善。
ps程式碼其中有一段 //???是我註解的,想問一下是不是那一段的問題。


[code]<select name="bzarea" size="1" style="font-size: 11pt; font-family: Arial; border: 1px solid #333333; background-color: #EEFFBB" onChange="document.getElementById('setQry').value='A';javascript:get(this.parentNode);">
<option selected value="Z">--- 請選擇 ---</option>
<?php
$result = mssql_query('ps_AreaHead') ;
while ($row = mssql_fetch_row($result))
{
?>
<option selected value="<?php echo $row[0]; ?>"><?php echo $row[1] ;?></option>
<?php
}

?>
<script>
document.myform.bzarea.selectedIndex = 0 ;
</script>
</select></td>
<td width="72" align="center" nowrap>
<p>會員選擇</td>
<td width="151" align="center" nowrap>
<p align="left">

<select id="bzgrp" size="1" style="font-size: 11pt; font-family: Arial; border: 1px solid #333333; background-color: #FFDDAA" onChange="document.getElementById('setQry').value='G';javascript:get(this.parentNode);">
<option selected value="Z">------ 請選擇 ------</option>
</select>

</td>
<td width="66" align="center" nowrap>
<p align="left">資料類型</td>
<td width="74" align="center" nowrap valign="top">
<p align="left">
&nbsp;<select name="bzrec" size="1" style="font-size: 11pt; font-family: Arial; border: 1px solid #333333; background-color: #DDEBFF">
</select></td>

<script type="text/javascript" language="javascript">
var http_request = false;
function makePOSTRequest(url, parameters) {
http_request = false;
//???
if (window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) {
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}

http_request.onreadystatechange = alertContents;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
}

function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
result = http_request.responseText;

if (result.substr(0,1) == "A")
{
conv = result.split(",") ;

removeOldSchool(document.myform.bzgrp) ;
appendOldSchool(document.myform.bzgrp,'------ 請選擇 ------','Z') ;

for ( i = 1 ; i < conv.length -1 ; i++) {
if (conv[i] == '3154' )
{
appendOldSchool(document.myform.bzgrp,'3898',conv[i].substr(0,4)) ;
}
else
{
appendOldSchool(document.myform.bzgrp,conv[i],conv[i].substr(0,4)) ;
}
}
}
else if (result.substr(0,1) == "G")
{
conv = result.split(",") ;

removeOldSchool(document.myform.bzrec) ;

for ( i = 1 ; i < conv.length ; i++) {
appendOldSchool(document.myform.bzrec,conv[i].substr(0,2),conv[i].substr(2,1)) ;
}
}
else
{
map.innerHTML = "" ;
conv = result.split(",") ;
parent.document.getElementById("online").innerHTML= conv[1] ;
document.getElementById("usrNo").innerHTML= conv[4] ;
document.getElementById("pigNo").innerHTML= conv[5] ;
document.getElementById('myspan').innerHTML = conv[6];

if ( (conv[2] != "") && (conv[3] != "")) {
initMap(conv[2],conv[3]) ;
}
}
} else {
//alert('There was a problem with the request.');
}
}
}


function get(obj) {
var area = document.myform.bzarea.selectedIndex ;
var grp = document.myform.bzgrp.selectedIndex ;
var rec = document.myform.bzrec.selectedIndex ;

if (rec >= 0 )
{
var poststr = "bzarea=" + trim(document.myform.bzarea.options[area].value) +
"&bzgrp=" + trim(document.myform.bzgrp.options[grp].value) +
"&bzrec=" + trim(document.myform.bzrec.options[rec].value) +
"&setQry=" + trim(document.getElementById("setQry").value ) ;
}
else
{
var poststr = "bzarea=" + trim(document.myform.bzarea.options[area].value) +
"&bzgrp=" + trim(document.myform.bzgrp.options[grp].value) +
"&setQry=" + trim(document.getElementById("setQry").value ) ;
}
makePOSTRequest('./include/perdetailResp.php', poststr);
}
</script>
<base target="eSMain">
<script language="javascript">

function waitMsg(p_flag,mod) {
if (p_flag == 1 ){
if (mod == 0 )
{
parent.scroll(0,0);
waitUsr.style.visibility = 'visible' ;
window.frames['usrList'].location.replace("about:blank") ;
window.frames['usrList'].location.replace("./usrList.php");
}
else
{
parent.scroll(0,0);
waitGrp.style.visibility = 'visible' ;
window.frames['grpList'].location.replace("about:blank") ;
window.frames['grpList'].location.replace("./grpList.php");
}
}
else
{
waitUsr.style.visibility = 'hidden' ;
waitGrp.style.visibility = 'hidden' ;
}
}


function hidediv()
{
document.getElementById("second").style.visibility = 'hidden' ;
}

function showdiv()
{
document.getElementById("second").style.visibility = 'visible' ;
}

function Init()
{
document.getElementById('myspan').innerHTML = "<?php echo $show; ?>";
var setQry = document.getElementById ('setQry') ;
setQry .style.display = 'none' ;
}

function trim(stringToTrim){ return stringToTrim.replace(/^\s+|\s+$/g,"");}

</script>

<!-- reload time -->
<script language="javascript" type="text/javascript">
var second = 61;
function countTime(){
if (second != 1){
second -= 1;
//document.getElementById('second').innerHTML = '更新倒數: '+second+' 秒';
document.getElementById('second').innerHTML = '';
}
else{
document.getElementById('second').innerHTML = '更新中....';
second = 61;

if ( (document.myform.bzarea.value != "Z") && (document.myform.bzgrp.value != "Z") ) {
document.getElementById('setQry').value='S';
javascript:get(this.parentNode);
}
}
setTimeout("countTime()",1000)

}
</script>
[/code]

本篇文章發表於2012-05-21 14:12
目前尚無任何回覆
   

回覆
如要回應,請先登入.