<script language="javascript">
function showfare()
{
var arrive=document.order.selectfare.value;
var zhi=document.order.selectfare.options[order.selectfare.selectedIndex].text;
var chaifen=arrive.split("&");
document.order.to.value=zhi;
document.order.fare.value=chaifen[0];
document.order.way.value=chaifen[1];
}
</script>这个JS是什么意思?
function showfare()
{
var arrive=document.order.selectfare.value;
var zhi=document.order.selectfare.options[order.selectfare.selectedIndex].text;
var chaifen=arrive.split("&");
document.order.to.value=zhi;
document.order.fare.value=chaifen[0];
document.order.way.value=chaifen[1];
}
</script>这个JS是什么意思?
function showfare()
{
var arrive=document.order.selectfare.value; // 取出当前被选中项的 value(即option元素中的value值)。
var zhi=document.order.selectfare.options[order.selectfare.selectedIndex].text; // 取出下拉列表框中显示的值。
var chaifen=arrive.split("&"); // 使用“&”拆分下列列表框中value值,形式估计是“AAA&BBB”样式的。
document.order.to.value=zhi; // 将下拉列表框中所显示的内容赋给order表单中的to(估计是个文本框)
document.order.fare.value=chaifen[0]; // 将下拉列表框中 value 的“AAA”传给fare。
document.order.way.value=chaifen[1]; // 将下拉列表框中 value 的“BBB”传给way。
}
因为在<select>的<option>中可以指定显示的内容(即你上面用到的zhi,是放在<option>和</option>之间的内容)和它的值(即上面的arrive,是放在<option>元素的value属性中的)。
估计要做的就是根据地点查询费用路线什么的。
根据这些代码段,只能写这么多了。那么早就起来研究啦,祝你顺利通答辩 o(·_·)o