在滑动门中由于htm代码都加载了的,但是我通过点击不同的栏目要提交不同的信息,这时就需要一个隐藏域的值做判断来写不同的sql,现在的问题就是当点击栏目时候要动态改变隐藏域的值,只把事例代码贴出来<style type="text/css">#test1 { width: 600px; }/* 头部总体 css */
.ntab2-head {
clear:both; height: 21px;
border-bottom: #c2130e 3px solid;
text-align: center;
}/* 头部标头的 css */
.ntab2-head p {
float:left; font-size: 14px; font-weight: bold;
width: 80px; height: 21px;
}/* 头部列表的 css */
.ntab2-head li {
float:left; background: #dcdcdc; border-left: #f2f2f2 1px solid;
width: 42px; cursor: pointer; font-size: 14px;
line-height: 21px; list-style-type: none;
}.ntab2-head li.current {
background: #c2130e; color: #ffffff; cursor: none;
}/* 主体内容的 css? */
.ntab2-body {
text-align: left;
}.ntab2-body dl {
text-indent: 0px; margin: 0px; padding: 0px;
}
</style>
<script language="javascript">
function ntab2_register(id, def)
{
var obj = document.getElementById(id);
if (!obj || !obj.hasChildNodes())
{
alert('ERROR: the object was not defined for #' + id + '#');
return;
} // get head & body object
var head = null;
var body = null;
for (var i = 0; i < obj.childNodes.length; i++)
{
var node = obj.childNodes[i];
if (node.tagName == 'DIV')
{
if (node.className == 'ntab2-head')
head = node;
else if (node.className == 'ntab2-body')
body = node;
}
}
if (!head) { alert('ERROR: head elements was not found for #' + id + '#'); return; }
if (!body) { alert('ERROR: body elements was not found for #' + id + '#'); return; } // set action & default
var items = head.getElementsByTagName('LI');
var datas = body.getElementsByTagName('DL');
if (items.length == 0) { alert('ERROR: empty set for head elements on #' + id + '#'); return; }
if (items.length != datas.length)
{
alert('ERROR: not equal between body.length and head.length for #' + id + '#');
return;
}
var total = items.length;
if (typeof def == 'undefined') def = 0;
else def = parseInt(def)%total;
if (def < 0) def += total;
for (var i = 0; i < total; i++)
{
datas[i].style.display = (i == def ? '' : 'none');
items[i].className = (i == def ? 'current' : '');
items[i].onclick = function() {
documnet.getElementById("hidden").value = documnet.getElementById("objslt").[documnet.getElementById("objslt").selectIndex].value;
for (var k = 0; k < total; k++)
{
datas[k].style.display = (this == items[k] ? '' : 'none');
items[k].className = (this == items[k] ? 'current' : '');
}
}
}
}
</script><form name="form2" method="post" action="overstock.asp">
<div id="test1">
<!-- 头部设定 -->
<div class="ntab2-head">
<p>新闻排行<p></p>
<li>国内</li>
<li>国际</li>
<li>社会</li>
<li>中国</li>
</div> <!-- 内容设定 -->
<div class="ntab2-body">
<dl>
国内-内容
</dl>
<dl>
国际-内容
</dl>
<dl>
社会-内容
</dl>
<dl>
中国
</dl>
<input type="hidden" name="hidden">
</div>
</div>
</font>
<script language="javascript">ntab2_register('test1', 3);</script>
.ntab2-head {
clear:both; height: 21px;
border-bottom: #c2130e 3px solid;
text-align: center;
}/* 头部标头的 css */
.ntab2-head p {
float:left; font-size: 14px; font-weight: bold;
width: 80px; height: 21px;
}/* 头部列表的 css */
.ntab2-head li {
float:left; background: #dcdcdc; border-left: #f2f2f2 1px solid;
width: 42px; cursor: pointer; font-size: 14px;
line-height: 21px; list-style-type: none;
}.ntab2-head li.current {
background: #c2130e; color: #ffffff; cursor: none;
}/* 主体内容的 css? */
.ntab2-body {
text-align: left;
}.ntab2-body dl {
text-indent: 0px; margin: 0px; padding: 0px;
}
</style>
<script language="javascript">
function ntab2_register(id, def)
{
var obj = document.getElementById(id);
if (!obj || !obj.hasChildNodes())
{
alert('ERROR: the object was not defined for #' + id + '#');
return;
} // get head & body object
var head = null;
var body = null;
for (var i = 0; i < obj.childNodes.length; i++)
{
var node = obj.childNodes[i];
if (node.tagName == 'DIV')
{
if (node.className == 'ntab2-head')
head = node;
else if (node.className == 'ntab2-body')
body = node;
}
}
if (!head) { alert('ERROR: head elements was not found for #' + id + '#'); return; }
if (!body) { alert('ERROR: body elements was not found for #' + id + '#'); return; } // set action & default
var items = head.getElementsByTagName('LI');
var datas = body.getElementsByTagName('DL');
if (items.length == 0) { alert('ERROR: empty set for head elements on #' + id + '#'); return; }
if (items.length != datas.length)
{
alert('ERROR: not equal between body.length and head.length for #' + id + '#');
return;
}
var total = items.length;
if (typeof def == 'undefined') def = 0;
else def = parseInt(def)%total;
if (def < 0) def += total;
for (var i = 0; i < total; i++)
{
datas[i].style.display = (i == def ? '' : 'none');
items[i].className = (i == def ? 'current' : '');
items[i].onclick = function() {
documnet.getElementById("hidden").value = documnet.getElementById("objslt").[documnet.getElementById("objslt").selectIndex].value;
for (var k = 0; k < total; k++)
{
datas[k].style.display = (this == items[k] ? '' : 'none');
items[k].className = (this == items[k] ? 'current' : '');
}
}
}
}
</script><form name="form2" method="post" action="overstock.asp">
<div id="test1">
<!-- 头部设定 -->
<div class="ntab2-head">
<p>新闻排行<p></p>
<li>国内</li>
<li>国际</li>
<li>社会</li>
<li>中国</li>
</div> <!-- 内容设定 -->
<div class="ntab2-body">
<dl>
国内-内容
</dl>
<dl>
国际-内容
</dl>
<dl>
社会-内容
</dl>
<dl>
中国
</dl>
<input type="hidden" name="hidden">
</div>
</div>
</font>
<script language="javascript">ntab2_register('test1', 3);</script>
re:
写不出来!不一定要用<input type='hidden'>用URL参数也可以呀!
<style type="text/css"> #test1 { width: 600px; } /* 头部总体 css */
.ntab2-head {
clear:both; height: 21px;
border-bottom: #c2130e 3px solid;
text-align: center;
} /* 头部标头的 css */
.ntab2-head p {
float:left; font-size: 14px; font-weight: bold;
width: 80px; height: 21px;
} /* 头部列表的 css */
.ntab2-head li {
float:left; background: #dcdcdc; border-left: #f2f2f2 1px solid;
width: 42px; cursor: pointer; font-size: 14px;
line-height: 21px; list-style-type: none;
} .ntab2-head li.current {
background: #c2130e; color: #ffffff; cursor: none;
} /* 主体内容的 css? */
.ntab2-body {
text-align: left;
} .ntab2-body dl {
text-indent: 0px; margin: 0px; padding: 0px;
}
</style>
<script language="javascript">
function ntab2_register(id, def) {
var obj = document.getElementById(id);
if (!obj || !obj.hasChildNodes()) {
alert('ERROR: the object was not defined for #' + id + '#');
return;
}
// get head & body object
var head = null;
var body = null;
for (var i = 0; i < obj.childNodes.length; i++) {
var node = obj.childNodes[i];
if (node.tagName == 'DIV'){
if (node.className == 'ntab2-head')
head = node;
else if (node.className == 'ntab2-body')
body = node;
}
}
if (!head) { alert('ERROR: head elements was not found for #' + id + '#'); return; }
if (!body) { alert('ERROR: body elements was not found for #' + id + '#'); return; }
// set action & default
var items = head.getElementsByTagName('LI');
var datas = body.getElementsByTagName('DL');
if (items.length == 0) { alert('ERROR: empty set for head elements on #' + id + '#'); return; }
if (items.length != datas.length){
alert('ERROR: not equal between body.length and head.length for #' + id + '#');
return;
}
var total = items.length;
if (typeof def == 'undefined') def = 0;
else def = parseInt(def)%total;
if (def < 0) def += total;
for (var i = 0; i < total; i++) {
datas[i].style.display = (i == def ? '' : 'none');
items[i].className = (i == def ? 'current' : '');
items[i].id = "test1_li_"+i ;
items[i].onclick = function() {
/////////////////////////////////////////////////////////
document.getElementById("hidden").value =this.id;
/////////////////////////////////////////////////////////
for (var k = 0; k < total; k++) {
datas[k].style.display = (this == items[k] ? '' : 'none');
items[k].className = (this == items[k] ? 'current' : '');
}
}
}
}
</script> <form name="form2" method="post" action="overstock.asp">
<div id="test1">
<!-- 头部设定 -->
<div class="ntab2-head">
<p>新闻排行 <p> </p>
<li>国内 </li>
<li>国际 </li>
<li>社会 </li>
<li>中国 </li>
</div> <!-- 内容设定 -->
<div class="ntab2-body">
<dl>
国内-内容
</dl>
<dl>
国际-内容
</dl>
<dl>
社会-内容
</dl>
<dl>
中国
</dl>
<input type="hidden" name="hidden" id="hidden">
</div>
</div>
<hr>
<input type=button onclick="alert(document.getElementById('hidden').value) " value="test">
</form>
<script language="javascript">ntab2_register('test1', 3); </script>