2010-11-12 98 views
-1

我對這個頁面有一個相當奇怪的問題。該頁面本身很醜,這可能不會對情況有很大幫助。隨機HTML元素不受javascript影響

在代碼中,您會看到當從下拉列表中選擇某個項目時,會調用一個javascript函數,該函數會根據選定的項目來使某些隱藏項目可見。但是,如果頁面上有20個以上的記錄,則會隨機跳過一些元素並保持隱藏狀態。它非常奇怪,因爲看似沒有跳過元素的模式。

這裏是JavaScript函數(第二個「如果」是我認爲這個問題是):

function fncEnable(x) 
    { 
     theform=document.form1  

      //first, we reset everything to be hidden and unchecked 
     document.getElementById("when"+x).style.visibility = "hidden"; 
     document.getElementById("first"+x).style.visibility = "hidden"; 
     document.getElementById("when2"+x).style.visibility = "hidden"; 
     document.getElementById("second"+x).style.visibility = "hidden"; 
     document.getElementById("when3"+x).style.visibility = "hidden"; 
     document.getElementById("third"+x).style.visibility = "hidden"; 
     document.getElementById("when4"+x).style.visibility = "hidden"; 
     document.getElementById("fourth"+x).style.visibility = "hidden"; 
     document.getElementById("sun"+x).checked = false; 
     document.getElementById("mon"+x).checked = false; 
     document.getElementById("tues"+x).checked = false; 
     document.getElementById("wed"+x).checked = false; 
     document.getElementById("thurs"+x).checked = false; 
     document.getElementById("fri"+x).checked = false; 
     document.getElementById("sat"+x).checked = false; 

     if(document.getElementById("howoften"+x).value == 1) 
     { 
      document.getElementById("sun"+x).checked = true; 
      document.getElementById("mon"+x).checked = true; 
      document.getElementById("tues"+x).checked = true; 
      document.getElementById("wed"+x).checked = true; 
      document.getElementById("thurs"+x).checked = true; 
      document.getElementById("fri"+x).checked = true; 
      document.getElementById("sat"+x).checked = true; 
      document.getElementById("sun"+x).disabled = false; 
      document.getElementById("mon"+x).disabled = false; 
      document.getElementById("tues"+x).disabled = false; 
      document.getElementById("wed"+x).disabled = false; 
      document.getElementById("thurs"+x).disabled = false; 
      document.getElementById("fri"+x).disabled = false; 
      document.getElementById("sat"+x).disabled = false; 
      document.getElementById("when"+x).style.visibility = "visible"; 
      document.getElementById("first"+x).style.visibility = "visible";//randomly, this line is skipped. 

     } 
     if(document.getElementById("howoften"+x).value == 2) 
     { 
      document.getElementById("sun"+x).checked = true; 
      document.getElementById("mon"+x).checked = true; 
      document.getElementById("tues"+x).checked = true; 
      document.getElementById("wed"+x).checked = true; 
      document.getElementById("thurs"+x).checked = true; 
      document.getElementById("fri"+x).checked = true; 
      document.getElementById("sat"+x).checked = true; 
      document.getElementById("sun"+x).disabled = false; 
      document.getElementById("mon"+x).disabled = false; 
      document.getElementById("tues"+x).disabled = false; 
      document.getElementById("wed"+x).disabled = false; 
      document.getElementById("thurs"+x).disabled = false; 
      document.getElementById("fri"+x).disabled = false; 
      document.getElementById("sat"+x).disabled = false; 
      document.getElementById("when"+x).style.visibility = "visible";//this line is never skipped; 
      document.getElementById("first"+x).style.visibility = "visible";//randomly, this line is skipped. 
      document.getElementById("when2"+x).style.visibility = "visible";//this line is never skipped. 
      document.getElementById("second"+x).style.visibility = "visible";//this line, is never skipped. 

     } 

     if(document.getElementById("howoften"+x).value == 3) 
     { 
      document.getElementById("sun"+x).checked = true; 
      document.getElementById("mon"+x).checked = true; 
      document.getElementById("tues"+x).checked = true; 
      document.getElementById("wed"+x).checked = true; 
      document.getElementById("thurs"+x).checked = true; 
      document.getElementById("fri"+x).checked = true; 
      document.getElementById("sat"+x).checked = true; 
      document.getElementById("sun"+x).disabled = false; 
      document.getElementById("mon"+x).disabled = false; 
      document.getElementById("tues"+x).disabled = false; 
      document.getElementById("wed"+x).disabled = false; 
      document.getElementById("thurs"+x).disabled = false; 
      document.getElementById("fri"+x).disabled = false; 
      document.getElementById("sat"+x).disabled = false; 
      document.getElementById("when"+x).style.visibility = "visible"; 
      document.getElementById("first"+x).style.visibility = "visible"; 
      document.getElementById("when2"+x).style.visibility = "visible"; 
      document.getElementById("second"+x).style.visibility = "visible"; 
      document.getElementById("when3"+x).style.visibility = "visible"; 
      document.getElementById("third"+x).style.visibility = "visible"; 
     } 

     if(document.getElementById("howoften"+x).value == 4) 
     { 
      document.getElementById("sun"+x).checked = true; 
      document.getElementById("mon"+x).checked = true; 
      document.getElementById("tues"+x).checked = true; 
      document.getElementById("wed"+x).checked = true; 
      document.getElementById("thurs"+x).checked = true; 
      document.getElementById("fri"+x).checked = true; 
      document.getElementById("sat"+x).checked = true; 
      document.getElementById("sun"+x).disabled = false; 
      document.getElementById("mon"+x).disabled = false; 
      document.getElementById("tues"+x).disabled = false; 
      document.getElementById("wed"+x).disabled = false; 
      document.getElementById("thurs"+x).disabled = false; 
      document.getElementById("fri"+x).disabled = false; 
      document.getElementById("sat"+x).disabled = false; 
      document.getElementById("when"+x).style.visibility = "visible"; 
      document.getElementById("first"+x).style.visibility = "visible"; 
      document.getElementById("when2"+x).style.visibility = "visible"; 
      document.getElementById("second"+x).style.visibility = "visible"; 
      document.getElementById("when3"+x).style.visibility = "visible"; 
      document.getElementById("third"+x).style.visibility = "visible"; 
      document.getElementById("when4"+x).style.visibility = "visible"; 
      document.getElementById("fourth"+x).style.visibility = "visible"; 
     } 




     if(document.getElementById("howoften"+x).value == 5) 
     { 
      document.getElementById("sun"+x).disabled = true; 
      document.getElementById("mon"+x).disabled = true; 
      document.getElementById("tues"+x).disabled = true; 
      document.getElementById("wed"+x).disabled = true; 
      document.getElementById("thurs"+x).disabled = true; 
      document.getElementById("fri"+x).disabled = true; 
      document.getElementById("sat"+x).disabled = true; 
      document.getElementById("sun"+x).checked = false; 
      document.getElementById("mon"+x).checked = false; 
      document.getElementById("tues"+x).checked = false; 
      document.getElementById("wed"+x).checked = false; 
      document.getElementById("thurs"+x).checked = false; 
      document.getElementById("fri"+x).checked = false; 
      document.getElementById("sat"+x).checked = false; 
      document.getElementById("when"+x).style.visibility = "visible"; 
      document.getElementById("first"+x).style.visibility = "visible"; 
     } 


     if(document.getElementById("howoften"+x).value == 6) 
     { 
      document.getElementById("sun"+x).disabled = true; 
      document.getElementById("mon"+x).disabled = true; 
      document.getElementById("tues"+x).disabled = true; 
      document.getElementById("wed"+x).disabled = true; 
      document.getElementById("thurs"+x).disabled = true; 
      document.getElementById("fri"+x).disabled = true; 
      document.getElementById("sat"+x).disabled = true; 
      document.getElementById("sun"+x).checked = false; 
      document.getElementById("mon"+x).checked = false; 
      document.getElementById("tues"+x).checked = false; 
      document.getElementById("wed"+x).checked = false; 
      document.getElementById("thurs"+x).checked = false; 
      document.getElementById("fri"+x).checked = false; 
      document.getElementById("sat"+x).checked = false; 
      document.getElementById("when"+x).style.visibility = "visible"; 
      document.getElementById("first"+x).style.visibility = "visible"; 
     } 

     if(document.getElementById("howoften"+x).value == 7) 
     { 
      document.getElementById("sun"+x).disabled = false; 
      document.getElementById("mon"+x).disabled = false; 
      document.getElementById("tues"+x).disabled = false; 
      document.getElementById("wed"+x).disabled = false; 
      document.getElementById("thurs"+x).disabled = false; 
      document.getElementById("fri"+x).disabled = false; 
      document.getElementById("sat"+x).disabled = false; 
      document.getElementById("sun"+x).checked = false; 
      document.getElementById("mon"+x).checked = false; 
      document.getElementById("tues"+x).checked = false; 
      document.getElementById("wed"+x).checked = false; 
      document.getElementById("thurs"+x).checked = false; 
      document.getElementById("fri"+x).checked = false; 
      document.getElementById("sat"+x).checked = false; 
      document.getElementById("when"+x).style.visibility = "visible"; 
      document.getElementById("first"+x).style.visibility = "visible"; 
     } 

     if(document.getElementById("howoften"+x).value == 8) 
     { 
      document.getElementById("sun"+x).disabled = true; 
      document.getElementById("mon"+x).disabled = true; 
      document.getElementById("tues"+x).disabled = true; 
      document.getElementById("wed"+x).disabled = true; 
      document.getElementById("thurs"+x).disabled = true; 
      document.getElementById("fri"+x).disabled = true; 
      document.getElementById("sat"+x).disabled = true; 
      document.getElementById("sun"+x).checked = false; 
      document.getElementById("mon"+x).checked = false; 
      document.getElementById("tues"+x).checked = false; 
      document.getElementById("wed"+x).checked = false; 
      document.getElementById("thurs"+x).checked = false; 
      document.getElementById("fri"+x).checked = false; 
      document.getElementById("sat"+x).checked = false; 

     } 

     if(document.getElementById("howoften"+x).value == 9) 
     { 
      document.getElementById("sun"+x).disabled = true; 
      document.getElementById("mon"+x).disabled = true; 
      document.getElementById("tues"+x).disabled = true; 
      document.getElementById("wed"+x).disabled = true; 
      document.getElementById("thurs"+x).disabled = true; 
      document.getElementById("fri"+x).disabled = true; 
      document.getElementById("sat"+x).disabled = true; 
      document.getElementById("sun"+x).checked = false; 
      document.getElementById("mon"+x).checked = false; 
      document.getElementById("tues"+x).checked = false; 
      document.getElementById("wed"+x).checked = false; 
      document.getElementById("thurs"+x).checked = false; 
      document.getElementById("fri"+x).checked = false; 
      document.getElementById("sat"+x).checked = false; 

     } 
     if(document.getElementById("howoften"+x).value == 10) 
     { 
      document.getElementById("sun"+x).disabled = true; 
      document.getElementById("mon"+x).disabled = true; 
      document.getElementById("tues"+x).disabled = true; 
      document.getElementById("wed"+x).disabled = true; 
      document.getElementById("thurs"+x).disabled = true; 
      document.getElementById("fri"+x).disabled = true; 
      document.getElementById("sat"+x).disabled = true; 
      document.getElementById("sun"+x).checked = false; 
      document.getElementById("mon"+x).checked = false; 
      document.getElementById("tues"+x).checked = false; 
      document.getElementById("wed"+x).checked = false; 
      document.getElementById("thurs"+x).checked = false; 
      document.getElementById("fri"+x).checked = false; 
      document.getElementById("sat"+x).checked = false; 
      document.getElementById("when"+x).style.visibility = "visible"; 
      document.getElementById("first"+x).style.visibility = "visible"; 

     } 

     if(document.getElementById("howoften"+x).value == 11) 
     { 

      document.getElementById("sun"+x).disabled = true; 
      document.getElementById("mon"+x).disabled = true; 
      document.getElementById("tues"+x).disabled = true; 
      document.getElementById("wed"+x).disabled = true; 
      document.getElementById("thurs"+x).disabled = true; 
      document.getElementById("fri"+x).disabled = true; 
      document.getElementById("sat"+x).disabled = true; 
      document.getElementById("when"+x).style.visibility = "visible"; 
      document.getElementById("first"+x).style.visibility = "visible"; 

     } 

     if(document.getElementById("howoften"+x).value == 12) 
     { 
      document.getElementById("sun"+x).disabled = true; 
      document.getElementById("mon"+x).disabled = true; 
      document.getElementById("tues"+x).disabled = true; 
      document.getElementById("wed"+x).disabled = true; 
      document.getElementById("thurs"+x).disabled = true; 
      document.getElementById("fri"+x).disabled = true; 
      document.getElementById("sat"+x).disabled = true; 
      document.getElementById("when"+x).style.visibility = "visible"; 
      document.getElementById("first"+x).style.visibility = "visible"; 

     } 
    } 

任何想法,爲什麼這些行將被忽略?

UPDATE:
我經歷了和重做功能有點所以這將是更小的,我仍然獲得相同的行爲。

function fncEnable(x) 
    { 
    var howoften = document.getElementById("howoften"+x).value; 
    if(howoften == 1 || howoften == 2 || howoften == 3 || howoften == 4) 
    { 
     document.getElementById("sun"+x).checked = true; 
     document.getElementById("mon"+x).checked = true; 
     document.getElementById("tues"+x).checked = true; 
     document.getElementById("wed"+x).checked = true; 
     document.getElementById("thurs"+x).checked = true; 
     document.getElementById("fri"+x).checked = true; 
     document.getElementById("sat"+x).checked = true; 
     document.getElementById("sun"+x).disabled = false; 
     document.getElementById("mon"+x).disabled = false; 
     document.getElementById("tues"+x).disabled = false; 
     document.getElementById("wed"+x).disabled = false; 
     document.getElementById("thurs"+x).disabled = false; 
     document.getElementById("fri"+x).disabled = false; 
     document.getElementById("sat"+x).disabled = false; 
    } 
    else if (howoften == 7) 
    { 
     document.getElementById("sun"+x).checked = false; 
     document.getElementById("mon"+x).checked = false; 
     document.getElementById("tues"+x).checked = false; 
     document.getElementById("wed"+x).checked = false; 
     document.getElementById("thurs"+x).checked = false; 
     document.getElementById("fri"+x).checked = false; 
     document.getElementById("sat"+x).checked = false; 
     document.getElementById("sun"+x).disabled = false; 
     document.getElementById("mon"+x).disabled = false; 
     document.getElementById("tues"+x).disabled = false; 
     document.getElementById("wed"+x).disabled = false; 
     document.getElementById("thurs"+x).disabled = false; 
     document.getElementById("fri"+x).disabled = false; 
     document.getElementById("sat"+x).disabled = false; 
    } 
    else 
    { 
     document.getElementById("sun"+x).checked = false; 
     document.getElementById("mon"+x).checked = false; 
     document.getElementById("tues"+x).checked = false; 
     document.getElementById("wed"+x).checked = false; 
     document.getElementById("thurs"+x).checked = false; 
     document.getElementById("fri"+x).checked = false; 
     document.getElementById("sat"+x).checked = false; 
     document.getElementById("sun"+x).disabled = true; 
     document.getElementById("mon"+x).disabled = true; 
     document.getElementById("tues"+x).disabled = true; 
     document.getElementById("wed"+x).disabled = true; 
     document.getElementById("thurs"+x).disabled = true; 
     document.getElementById("fri"+x).disabled = true; 
     document.getElementById("sat"+x).disabled = true; 
    } 

    if(howoften == 4) 
    { 
     document.getElementById("when"+x).style.visibility = "visible"; 
     document.getElementById("first"+x).style.visibility = "visible"; 

     document.getElementById("when2"+x).style.visibility = "visible"; 
     document.getElementById("second"+x).style.visibility = "visible"; 

     document.getElementById("when3"+x).style.visibility = "visible"; 
     document.getElementById("third"+x).style.visibility = "visible"; 

     document.getElementById("when4"+x).style.visibility = "visible"; 
     document.getElementById("fourth"+x).style.visibility = "visible"; 
    } 
    else if (howoften == 3) 
    { 
     document.getElementById("when"+x).style.visibility = "visible"; 
     document.getElementById("first"+x).style.visibility = "visible"; 

     document.getElementById("when2"+x).style.visibility = "visible"; 
     document.getElementById("second"+x).style.visibility = "visible"; 

     document.getElementById("when3"+x).style.visibility = "visible"; 
     document.getElementById("third"+x).style.visibility = "visible"; 

     document.getElementById("when4"+x).style.visibility = "hidden"; 
     document.getElementById("fourth"+x).style.visibility = "hidden"; 
    } 
    else if (howoften == 2) 
    { 
     document.getElementById("when"+x).style.visibility = "visible"; 
     document.getElementById("first"+x).style.visibility = "visible"; 

     document.getElementById("when2"+x).style.visibility = "visible"; 
     document.getElementById("second"+x).style.visibility = "visible"; 

     document.getElementById("when3"+x).style.visibility = "hidden"; 
     document.getElementById("third"+x).style.visibility = "hidden"; 

     document.getElementById("when4"+x).style.visibility = "hidden"; 
     document.getElementById("fourth"+x).style.visibility = "hidden"; 
    } 
    else if (howoften == 1) 
    { 
     document.getElementById("when"+x).style.visibility = "visible"; 
     document.getElementById("first"+x).style.visibility = "visible"; 

     document.getElementById("when2"+x).style.visibility = "hidden"; 
     document.getElementById("second"+x).style.visibility = "hidden"; 

     document.getElementById("when3"+x).style.visibility = "hidden"; 
     document.getElementById("third"+x).style.visibility = "hidden"; 

     document.getElementById("when4"+x).style.visibility = "hidden"; 
     document.getElementById("fourth"+x).style.visibility = "hidden"; 
    } 
    else 
    { 
     document.getElementById("when"+x).style.visibility = "hidden"; 
     document.getElementById("first"+x).style.visibility = "hidden"; 

     document.getElementById("when2"+x).style.visibility = "hidden"; 
     document.getElementById("second"+x).style.visibility = "hidden"; 

     document.getElementById("when3"+x).style.visibility = "hidden"; 
     document.getElementById("third"+x).style.visibility = "hidden"; 

     document.getElementById("when4"+x).style.visibility = "hidden"; 
     document.getElementById("fourth"+x).style.visibility = "hidden"; 
    } 

它可能不是最好的方法,但它只花了幾分鐘。

至於HTML,它看起來很適合我,但我可能會錯過一些東西。這裏是相關的內容:

<table border="0" align="left" style="padding-bottom:10px"> 
    <tr valign="baseline"> 
     <td align="left" width="25%">Day(s) of the Week: </td> 
     <td>Sun</td> 
     <td>Mon</td> 
     <td>Tues</td> 
     <td>Wed</td> 
     <td>Thurs</td> 
     <td>Fri</td> 
     <td>Sat</td> 
    </tr> 

    <tr valign="baseline"> 

     <td>&nbsp;</td> 
     <td><input type="checkbox" disabled="disabled" id="sun<cfoutput>#Peoplecount#</cfoutput>" name="sun<cfoutput>#Peoplecount#</cfoutput>" value="" /></td> 
     <td><input type="checkbox" disabled="disabled" id="mon<cfoutput>#Peoplecount#</cfoutput>" name="mon<cfoutput>#Peoplecount#</cfoutput>" value="" /></td> 
     <td><input type="checkbox" disabled="disabled" id="tues<cfoutput>#Peoplecount#</cfoutput>" name="tues<cfoutput>#Peoplecount#</cfoutput>" value="" /></td> 
     <td><input type="checkbox" disabled="disabled" id="wed<cfoutput>#Peoplecount#</cfoutput>" name="wed<cfoutput>#Peoplecount#</cfoutput>" value="" /></td> 
     <td><input type="checkbox" disabled="disabled" id="thurs<cfoutput>#Peoplecount#</cfoutput>" name="thurs<cfoutput>#Peoplecount#</cfoutput>" value="" /></td> 
     <td><input type="checkbox" disabled="disabled" id="fri<cfoutput>#Peoplecount#</cfoutput>" name="fri<cfoutput>#Peoplecount#</cfoutput>" value="" /></td> 
     <td><input type="checkbox" disabled="disabled" id="sat<cfoutput>#Peoplecount#</cfoutput>" name="sat<cfoutput>#Peoplecount#</cfoutput>" value="" /></td> 

    </tr> 
</table> 
<table border="0" align="left" style="padding-bottom:10px"> 
    <tr valign="baseline"> 
     <td width="25%"><label style="visibility:hidden" id="first<cfoutput>#Peoplecount#</cfoutput>">Dose Time:</label></td> 
     <td width="25%"><label style="visibility:hidden" id="second<cfoutput>#Peoplecount#</cfoutput>">Second Dose:</label></td> 
     <td width="25%"><label style="visibility:hidden" id="third<cfoutput>#Peoplecount#</cfoutput>">Third Dose:</label></td> 
     <td width="25%"><label style="visibility:hidden" id="fourth<cfoutput>#Peoplecount#</cfoutput>">Fourth Dose:</label></td> 
    </tr> 
    <tr> 
     <td> 
      <select name="when<cfoutput>#Peoplecount#</cfoutput>" style="visibility:hidden" size="1" id="when<cfoutput>#Peoplecount#</cfoutput>"> 
       <option value="">Select A Time</option> 
       <cfloop query="thetimes"> 
        <option value="<cfoutput>#TimeFormat(thetimes.hourlytimes,'h:mm tt')#</cfoutput>"><cfoutput>#TimeFormat(thetimes.hourlytimes,'h:mm tt')#</cfoutput></option> 
       </cfloop> 
      </select> 
      &nbsp; 
     </td> 


     <td> 
      <select name="when2<cfoutput>#Peoplecount#</cfoutput>" style="visibility:hidden" size="1" id="when2<cfoutput>#Peoplecount#</cfoutput>"> 
       <option value="">Select A Time</option> 
       <cfloop query="thetimes"> 
        <option value="<cfoutput>#TimeFormat(thetimes.hourlytimes,'h:mm tt')#</cfoutput>"><cfoutput>#TimeFormat(thetimes.hourlytimes,'h:mm tt')#</cfoutput></option> 
       </cfloop> 
      </select> 
      &nbsp; 
     </td> 


     <td> 
      <select name="when3<cfoutput>#Peoplecount#</cfoutput>" style="visibility:hidden" size="1" id="when3<cfoutput>#Peoplecount#</cfoutput>"> 
       <option value="">Select A Time</option> 
       <cfloop query="thetimes"> 
        <option value="<cfoutput>#TimeFormat(thetimes.hourlytimes,'h:mm tt')#</cfoutput>"><cfoutput>#TimeFormat(thetimes.hourlytimes,'h:mm tt')#</cfoutput></option> 
       </cfloop> 
      </select> 
      &nbsp; 
     </td> 

     <td> 
      <select name="when4<cfoutput>#Peoplecount#</cfoutput>" style="visibility:hidden" size="1" id="when4<cfoutput>#Peoplecount#</cfoutput>"> 
       <option value="">Select A Time</option> 
       <cfloop query="thetimes"> 
        <option value="<cfoutput>#TimeFormat(thetimes.hourlytimes,'h:mm tt')#</cfoutput>"><cfoutput>#TimeFormat(thetimes.hourlytimes,'h:mm tt')#</cfoutput></option> 
       </cfloop> 
       </select> 
      &nbsp; 
     </td> 
    </tr> 
</table> 

我知道這是可怕的,但這就是爲什麼我不想重做它。我有我自己的事情要做,如果我能避免,我不想花大量時間重做別人的工作。

UPDATE 2: 我剛剛發現了一些東西。我不知道它是否會有幫助,但我會提到它。

我發現,如果我在警報中引發有問題的元素的可見性,它會顯示「可見」,但該元素在頁面上絕對不可見。

我還發現,在Firefox中的行爲是相同的。

它開始看起來像它總是第21個元素,所以「when21」。 從頭開始。它只在以0結束的元素上起作用。所以像when40when30顯示,但不是when31when25

+0

你確定你的HTML有效嗎? – 2010-11-12 00:19:15

+3

需要漂白我的眼睛asap ....雖然,seriosuly,你有沒有考慮縮短這一點?例如。對象地圖等 – 2010-11-12 00:20:53

+0

你測試過哪些瀏覽器? – Jan 2010-11-12 00:23:57

回答

0

好的,這是我想出來的。

我所做的只是將when + x的名稱下拉爲when1 + x

所以:

if(howoften != 8 && howoften != 9) 
    { 
     document.getElementById("first"+x).style.visibility = "visible"; 
     document.getElementById("when1"+x).style.visibility = "visible"; 
    } 
    else 
    { 
     document.getElementById("when1"+x).style.visibility = "hidden"; 
     document.getElementById("first"+x).style.visibility = "hidden"; 
    } 

... etc... 

<select name="when1<cfoutput>#Peoplecount#</cfoutput>" style="visibility:hidden" size="1" id="when1<cfoutput>#Peoplecount#</cfoutput>"> 
    <option value="">Select A Time</option> 
    <cfloop query="thetimes"> 
     <option value="<cfoutput>#TimeFormat(thetimes.hourlytimes,'h:mm tt')#</cfoutput>"><cfoutput>#TimeFormat(thetimes.hourlytimes,'h:mm tt')#</cfoutput></option> 
    </cfloop> 
</select> 

出於某種原因,我不明白,現在一切都工作得很好。我甚至嘗試將when更改爲j_thing之類的東西,但它仍然無效。只有當它有'1'的時候纔有效。

如果有人能解釋爲什麼這個工程,我會很感激。

1

嘗試查看案例,並可能在您的HTML文檔中重複使用ID。

旁邊,在某些情況下,由於使用visibility,您可能會遇到一些問題。嘗試用display: none而不是visibility: hidden做一些測試。

要再次顯示元素,可以使用display: block,display: inlinethe other possibility of display,具體取決於您操作的元素。