if i run the same code for IE every thing is fine i am getting the value of selectedId where as for firefox and chrome it is giving values Undefine.
----------------- code -------------------------------
<html>
<head>
<script type="text/javascript">
function createSelected()
{
var value;
var theForm = document.hell;
for (var i = 0; i < theForm.length; i++)
{
var e = theForm.elements[i];
if ((e.type == "hidden") && (e.value == "false"))
{
console.log("the value of selected IDS="+e.selectedId);
if (e.selectedId!= undefined )
{
Value = ", "+e.selectedId;
}
}
}
console.log( Value);
}
</script>
</head>
<body>
<form name="hell">
<h1>This working only with IE not with FireFox and Crome </h1>
<br/>
<br/>
<input type="hidden" selectedId="heyya1" name="item1" value="false">h1</input>
<input type="hidden" selectedId="heyya2" name="item2" value="false">h2</input>
<input type="hidden" selectedId="heyya3" name="item3" value="false">h3</input>
<input type="hidden" selectedId="heyya4" name="item4" value="false">h4</input>
<input type="hidden" selectedId="heyya5" name="item5" value="false">h5</input>
<input type="hidden" selectedId="heyya6" name="item6" value="false">h6</input>
<input type="button" onclick=createSelected() value="find the values"></input>
</form>
</body>
---------------------------code end-----------------------------------------
please help in in this why cant we use other parameter( like Selectedid inside HTML tag) in FireFox like we can do it in IE.
thanks in advance..
Try reading the selectedId as below. Use getAttribute method
alert("the value of selected IDS="+e.getAttribute('selectedId'));
In Chrome (sorry, I'm using a computer that doesn't have FF, and I'm not going to install it just for this question) it works if you use
.getAttribute()
. So:Or, in your function:
Also, note that JavaScript is case sensitive, so your variable
value
is not the same asValue
, and you were sayingValue =
where you probably meantvalue +=
. And you may want to use quotes around your element attributes:onclick="createSelected()"
.