views:

135

answers:

1

Hi all, i am developing a gadget and i am using JavaScript to change innerHTML of span, but after some operations i need to read that value. Additionally i am using pre-entered value for spans but when i try to read new data function loads pre-entered one. Is there any solution for that?

JS:

function read_write(condition,filename){
    var fso  = new ActiveXObject('Scripting.FileSystemObject');
    var fh = fso.OpenTextFile(System.Gadget.path+'\\'+filename+'.txt',condition, true,-2);
    if (condition == 1) {
    var result = fh.ReadLine();
    return result;      
    } 
    else if (condition == 2) {
    var spn1 = document.getElementById('span1').innerHTML;
    fh.WriteLine(spn1+','+document.getElementById('span2').innerHTML);
    }
    fh.Close();
}

HTML:

<table id="sonuc">
  <tbody>
    <tr>
      <td style="width:50%" valign="top">
        <span class="result" id="span1"></span><br/>
        <span class="result" id="span2"></span>
      </td>
    </tr>
  </tbody>
</table> 
A: 

If you're using innerHTML to write to the span element, you should be able to use it again to read. How are you trying to read until now?

Fábio Batista
I am using document.getElementById('span1').innerHTML = data[0];to change inner part of spanas you can guess, data is an array of some values...
Alper
You all right, i can read now. Icouldn't before because my coding fault..
Alper