ak_jsohi4u
05-09-2006, 02:40 PM
Hii,
I am trying to parse the innerHTML like this...
//InnerHTML = "<INPUT id=TreeViewPR1_TreeView1n14CheckBox title=Hostage type=checkbox CHECKED name=TreeViewPR1_TreeView1n14CheckBox>
//<SPAN class=\"TreeViewPR1_TreeView1_0 TreeViewPR1_TreeView1_1\" id=TreeViewPR1_TreeView1t14 title='Extract This string'>Hostage</SPAN>"
function AddNodeid(InnerHTML)
{
var TitleIndex=InnerHTML.lastIndexOf("title=");
if (TitleIndex > 0)
{
var SubString= InnerHTML.substring(TitleIndex+6, InnerHTML.length+1);
var EndIndex=SubString.indexOf("id="); // For Firefox
if(EndIndex <=0)
EndIndex=SubString.indexOf(">"); // For IE
var Nodeid=SubString.substring(0, EndIndex);
alert(Nodeid);
}
else
alert("No NodeId");
}
the problems are becoz of browsers..
Firefox interchanges the positions of title and id in <SPAN> tag...
and another prob with this code is that IE returns id without quotes( i.e 01) but FF returnsin double quotes(i.e "01").
can you tell why this happens and is there a way by which I can directly get
title, value pair.:confused:
Thanks in advance..
Cheerio
Abhishek
I am trying to parse the innerHTML like this...
//InnerHTML = "<INPUT id=TreeViewPR1_TreeView1n14CheckBox title=Hostage type=checkbox CHECKED name=TreeViewPR1_TreeView1n14CheckBox>
//<SPAN class=\"TreeViewPR1_TreeView1_0 TreeViewPR1_TreeView1_1\" id=TreeViewPR1_TreeView1t14 title='Extract This string'>Hostage</SPAN>"
function AddNodeid(InnerHTML)
{
var TitleIndex=InnerHTML.lastIndexOf("title=");
if (TitleIndex > 0)
{
var SubString= InnerHTML.substring(TitleIndex+6, InnerHTML.length+1);
var EndIndex=SubString.indexOf("id="); // For Firefox
if(EndIndex <=0)
EndIndex=SubString.indexOf(">"); // For IE
var Nodeid=SubString.substring(0, EndIndex);
alert(Nodeid);
}
else
alert("No NodeId");
}
the problems are becoz of browsers..
Firefox interchanges the positions of title and id in <SPAN> tag...
and another prob with this code is that IE returns id without quotes( i.e 01) but FF returnsin double quotes(i.e "01").
can you tell why this happens and is there a way by which I can directly get
title, value pair.:confused:
Thanks in advance..
Cheerio
Abhishek