how to keep innerHTML value unchanged?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jsutariya
    New Member
    • Jun 2010
    • 2

    how to keep innerHTML value unchanged?

    how to append the value of innerHTML in javascript without changing the first inserted values?
    I have generated a combobox in my page and creating new combobox using ajax.
    but when I try to add new combobox the selected value of previous combobox is get reset.
    How can I avoid it.

    Code:
    batch_field=document.getElementById('stock_add').innerHTML;
    		batch_field = batch_field.concat(xmlhttp3.responseText);
    		document.getElementById('stock_add').innerHTML = batch_field;
    I am using upper code to append the first innerHTML value in the next created innerHTML.
    Last edited by gits; Jun 8 '10, 03:02 PM. Reason: added code tags
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you can use the Shorthand Assignment Operators. in your case: +=.

    Comment

    • jsutariya
      New Member
      • Jun 2010
      • 2

      #3
      still not working..
      will you please provide your own example or code??

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        something as simple as that
        Code:
        document.getElementById('stock_add').innerHTML += xmlhttp3.responseText;

        Comment

        Working...