Get value from innerHTML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • solaris7
    New Member
    • Oct 2011
    • 1

    Get value from innerHTML

    Hi Guys,
    I managed to get the innerHTML of a cell value in a table and it looks like this:

    <input value="1234" type="pass">

    How do I just get the value "1234" from the above HTML?
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    It is not a good practice to use inneHTML for getting the values. Even if you wish to use so, you can get the value like this

    Code:
    var innerObj = innerHTMLObject;
    var index = innerObj.indexOf("value=");
    var objValue = "";
    if(index>0){
            index+=7;
    	var tempStr = innerObj.substring(index,innerObj.lenght);
    	var tempIndex = tempStr.indexOf("\"");
    	tempIndex+=index;
    	objValue = innerObj.substring(index,tempIndex);
    	//alert("value = "+objValue);
    	}
    This is a way. But this is not a good way to achieve, since you have to do another logic to read the value. Just google for parsing the column values of a table.

    Thanks and Regards
    Ramanan Kalirajan
    Last edited by RamananKalirajan; Oct 25 '11, 06:02 AM. Reason: Added the Code Tag

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      probably something easy as obj.getElements ByTagName("inpu t")[0].value

      Comment

      Working...