firefox和innerHTML [英] firefox and innerHTML

查看:83
本文介绍了firefox和innerHTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么不是SELECT元素'的innerHTML反映了选择哪个选项是什么?b $ b?适用于IE。我需要这个功能,以便我可以保留用户在选项卡界面中做出的选择。


<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Transitional // EN"

" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

< html xmlns =" http://w3.org/1999/xhtml">

< head>


< script language =" javascript">

函数callAlert(){

var theHTML = document.getElementById(''Radius'')。innerHTML;

// alert(the HTML);

}

< / script>

< title> Untitled Document< / title> ;

< / head>


< body>

< form id =" myForm">

< div id =" myDiv">

< table border =" 0"宽度= QUOT; 430" CELLPADDING = QUOT; 3英寸cellspacing =" 0">

< tr>

< td font color ="#ff0000"> *< / font> Radius:< ; / td>

< td width =" 331"高度= QUOT; 30英寸; class =" formData">

< select onChange =" callAlert();" ID = QUOT;半径" name =" Radius">

< option value =" .10" id =" 0"> 1/10英里< /选项>

<选项值=" .20"> 1/5英里< /选项>

< option value =" .25"> 1/4英里< /选项>

< option value =" .5"> 1/2英里< /选项>

< option value =" .75"> 3/4英里< / option>

< option value =" 1"> 1英里< / option>

< / select>

< / td>

< / tr>

< / table>

< / div>

< / form>

< / body>

< / html>

解决方案

2005年7月10日23:20,bedhead写道:
< blockquote class =post_quotes>为什么SELECT元素'的innerHTML反映哪个选项被选中?


所选属性是指预选,而不是当前是否选择元素

。标记是静态的,并且不会对用户操作的响应进行更改。

我需要此功能以便我可以保留用户所做的选择一个标签式界面。




从对象属性中读取值并稍后重新分配。


[snip]


Mike


-

迈克尔·温特

前缀主题[新闻]在回复之前电子邮件。


bedhead写道:

为什么没有SELECT元素'的innerHTML反映哪个选项被选中?适用于IE。我需要这个功能,以便我可以保留用户在选项卡式界面中做出的选择。


你在找什么?选项'的值,选项'的文字或

选项'的选定索引?

[...]
< script language =" javascript">
函数callAlert(){
var theHTML = document.getElementById(''Radius'')。innerHTML;
// alert(theHTML);
$
< / script>




为什么不将select对象传递给callAlert函数?


< script type =" text / javascript">

function callAlert(menu){

alert(menu.options [menu.selectedIndex] .value);

alert(menu.options [menu.selectedIndex] .text);

alert(menu.selectedIndex);

}

< / script>


< select onChange =" callAlert(this);" ID = QUOT;半径" name =" Radius">


帮助?

[...]


Mick


bedhead< ms *** @ consultshaw.com>在消息新闻中写道:11 ********************** @ g43g2000cwa.googlegr oups.com ...

为什么没有'' ta SELECT元素'的innerHTML反映哪个选项被选中?适用于IE。我需要这个功能,以便我可以保留用户在选项卡界面中做出的选择。



http://jibbering.com/FAQ/#FAQ4_13


使用上述技巧,分配表格名称不是ID。阅读表单元素不涉及

document.getElementById或.innerHTML。请告诉你所有的朋友,让他们告诉他们所有的朋友等。


-

Stephen Chalmers

Why doesn''t a SELECT element''s innerHTML reflected which option was
selected? Works in IE. I need this functionality so that I can retain
what choices a user made in a tabbed interface.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://w3.org/1999/xhtml">
<head>

<script language="javascript">
function callAlert(){
var theHTML = document.getElementById(''Radius'').innerHTML;
//alert(theHTML);
}
</script>
<title>Untitled Document</title>
</head>

<body>
<form id="myForm">
<div id="myDiv">
<table border="0" width="430" cellpadding="3" cellspacing="0">
<tr>
<td font color="#ff0000">*</font>Radius:</td>
<td width="331" height="30" class="formData">
<select onChange="callAlert();" id="Radius" name="Radius">
<option value=".10" id="0">1/10 mile</option>
<option value=".20">1/5 mile</option>
<option value=".25">1/4 mile</option>
<option value=".5">1/2 mile</option>
<option value=".75">3/4 mile</option>
<option value="1">1 mile</option>
</select>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

解决方案

On 10/07/2005 23:20, bedhead wrote:

Why doesn''t a SELECT element''s innerHTML reflected which option was
selected?
The selected attribute refers to pre-selection, not whether the element
is currently selected. Markup is static and doesn''t change in response
to user actions.
I need this functionality so that I can retain what choices a user
made in a tabbed interface.



Read the values from object properties and reassign them later.

[snip]

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.


bedhead wrote:

Why doesn''t a SELECT element''s innerHTML reflected which option was
selected? Works in IE. I need this functionality so that I can retain
what choices a user made in a tabbed interface.
What are you looking for? The option''s value, the option''s text or the
option''s selected index?
[...]
<script language="javascript">
function callAlert(){
var theHTML = document.getElementById(''Radius'').innerHTML;
//alert(theHTML);
}
</script>



Why not pass the select object to the callAlert function?

<script type="text/javascript">
function callAlert(menu){
alert(menu.options[menu.selectedIndex].value);
alert(menu.options[menu.selectedIndex].text);
alert(menu.selectedIndex);
}
</script>

<select onChange="callAlert(this);" id="Radius" name="Radius">

Help?
[...]

Mick


bedhead <ms***@consultshaw.com> wrote in message news:11**********************@g43g2000cwa.googlegr oups.com...

Why doesn''t a SELECT element''s innerHTML reflected which option was
selected? Works in IE. I need this functionality so that I can retain
what choices a user made in a tabbed interface.



http://jibbering.com/FAQ/#FAQ4_13

Using the above technique, assign your form a NAME not an ID. Reading form elements does not involve
document.getElementById or .innerHTML. Please tell all your friends and ask them to tell all their friends etc.

--
Stephen Chalmers


这篇关于firefox和innerHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆