Javascript Can';t使用html表单和infobox.js显示默认文本
网页设计师新手在这里,所以我希望这些术语是正确的,这个问题不是太尴尬。我得到的是一个html表单(在html5文档中),包含4项(尽管还有更多):Javascript Can';t使用html表单和infobox.js显示默认文本,javascript,forms,infobox,Javascript,Forms,Infobox,网页设计师新手在这里,所以我希望这些术语是正确的,这个问题不是太尴尬。我得到的是一个html表单(在html5文档中),包含4项(尽管还有更多): 选择一页 第1页 第2页 第3页 …以及这3个页面中每个页面的文本,都使用CSS隐藏。首次打开或刷新页面时,“选择页面”在表单菜单框中可见。当一个页面被选中时,“infobox.js”(我很多年前在网上的某个地方找到的)会使该页面的文本在菜单框下方可见。工作完美 我想要的是:当页面第一次打开时,“选择页面”在表单菜单框中可见,并且页面1的文本在其下方
function selectForm1(frm){
/* Select the div containing all the hidden forms */
var hiddenForms1 = document.getElementById("allForms1");
/* Select every form within the above div and assign it to an array */
theForm1 = hiddenForms1.getElementsByTagName("form");
/* Set the display for each of the above forms to NONE */
for(x=0; x<theForm1.length; x++){
theForm1[x].style.display = "none";
}
/* If the form selected from the list exists, set its display to BLOCK */
if (theForm1[frm-1]){
theForm1[frm-1].style.display = "block";
}
}
功能选择表单1(frm){
/*选择包含所有隐藏表单的div*/
var hiddenForms1=document.getElementById(“allForms1”);
/*选择上述div中的每个表单并将其分配给数组*/
theForm1=hiddenForms1.getElementsByTagName(“表单”);
/*将上述每个表单的显示设置为“无”*/
对于(x=0;xOK,I f-I-n-a-l-l-y-在又一次猜测后得到了它。这成功了:
<body onload="selectForm1(1)">
function selectForm1(frm){
/* Select the div containing all the hidden forms */
var hiddenForms1 = document.getElementById("allForms1");
/* Select every form within the above div and assign it to an array */
theForm1 = hiddenForms1.getElementsByTagName("form");
/* Set the display for each of the above forms to NONE */
for(x=0; x<theForm1.length; x++){
theForm1[x].style.display = "none";
}
/* If the form selected from the list exists, set its display to BLOCK */
if (theForm1[frm-1]){
theForm1[frm-1].style.display = "block";
}
}
<body onload="selectForm1(1)">