innerHTML forms et FF

O

OAM

Hi,

Why this code work with IE and not with FF

1- add an input
2- enter a value
3 -add a second input

With FF, the value is lost, not avec IE !

Thanks

Olivier.

----------

<html>
<head>

<script type="text/javascript">
var indice_sensor=0;
function add_sensor() {
indice_sensor=indice_sensor+1;

if (indice_sensor == 1)
document.getElementById('add_sensor').innerHTML=
indice_sensor+":&nbsp;<input type='text'
name='Sensor_Name["+indice_sensor+"]' id='Sensor_Name"+indice_sensor+"'/><br
/>";
else
document.getElementById('add_sensor').innerHTML=
document.getElementById('add_sensor').innerHTML
+indice_sensor+":&nbsp;<input type='text'
name='Sensor_Name["+indice_sensor+"]' id='Sensor_Name"+indice_sensor+"'/><br
/>";
}
</script>

</head>
<body>

<form>
<div>
<span id='add_sensor'></span>
</div>
</form>
<a href="#" onClick="javascript:add_sensor()">Click</a>

</body>
 
A

ASM

OAM a écrit :
Hi,

Why this code work with IE and not with FF

1- add an input
2- enter a value
3 -add a second input

<html>
<script type="text/javascript">

var idx=0;

function addInput(idWhere) {
idx ++;
var target = document.getElementById(idWhere);
var txt = document.createTextNode(idx+' : ');
var elt = document.createElement('INPUT');
elt.name = 'Sensor_Name['+idx+']';
elt.id = 'Sensor_Name'+idx;
var br = document.createElement('BR');
target.appendChild(txt);
target.appendChild(elt);
target.appendChild(br);
}
</script>

<button onclick="addInput('ici');">Add input</button>
<p id="ici"></p>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top