Loading ...
Sorry, an error occurred while loading the content.
 

Data Source doesn't load from a hidden HTML element

Expand Messages
  • Radu
    I am trying to load data into the datasource from a local array that changes dynamically. Here is the example that doesn t work followed ... [... some HTML
    Message 1 of 3 , Jan 30, 2008
      I am trying to load data into the datasource from a local array that
      changes dynamically. Here is the example that doesn't work followed
      by the static code that works :

      ---------------------- IT DOESN'T WORK: ----------
      [... some HTML code ...]

      <div id="ARRAY_DIV" style="display: none">
      <textarea id="arrayHolder">["1","-","-","-","-","-","-"],["2","-","-
      ","-","-","-","-"]</textarea>
      </div>

      [... some HTML code followed by the javascript code containing ...]

      // Data Source from a local array
      var txt = document.getElementById('arrayHolder').value;
      var myDataSource = new YAHOO.util.DataSource(
      [
      txt
      ],
      {responseType: YAHOO.util.DataSource.TYPE_JSARRAY}
      );

      ---------------------- IT DOES WORK: ----------
      Strangely enough, everything works fine if I put:

      var myDataSource = new YAHOO.util.DataSource(
      [
      [1","-","-","-","-","-","-"],["2","-","-","-","-","-","-"]
      ],
      {responseType: YAHOO.util.DataSource.TYPE_JSARRAY}
      );

      Can anyone tell me the solution? I need to dynamically place the
      values in the array at the loading time, I can't use a datasource
      with previously set values.

      Thank you in advance!
    • Satyam
      The value of the innerHTML of a textarea (or any innerHTML, for that matter) is a string even if it follows the syntax of a JavaScript array, it could follow
      Message 2 of 3 , Jan 31, 2008
        The value of the innerHTML of a textarea (or any innerHTML, for that matter)
        is a string even if it follows the syntax of a JavaScript array, it could
        follow the syntax of a COBOL array, if such a thing exists, and it wouldn't
        make it one, it would still be just a string.

        Satyam

        ----- Original Message -----
        From: "Radu" <rorghi@...>
        To: <ydn-javascript@yahoogroups.com>
        Sent: Wednesday, January 30, 2008 9:18 PM
        Subject: [ydn-javascript] Data Source doesn't load from a hidden HTML
        element


        >I am trying to load data into the datasource from a local array that
        > changes dynamically. Here is the example that doesn't work followed
        > by the static code that works :
        >
        > ---------------------- IT DOESN'T WORK: ----------
        > [... some HTML code ...]
        >
        > <div id="ARRAY_DIV" style="display: none">
        > <textarea id="arrayHolder">["1","-","-","-","-","-","-"],["2","-","-
        > ","-","-","-","-"]</textarea>
        > </div>
        >
        > [... some HTML code followed by the javascript code containing ...]
        >
        > // Data Source from a local array
        > var txt = document.getElementById('arrayHolder').value;
        > var myDataSource = new YAHOO.util.DataSource(
        > [
        > txt
        > ],
        > {responseType: YAHOO.util.DataSource.TYPE_JSARRAY}
        > );
        >
        > ---------------------- IT DOES WORK: ----------
        > Strangely enough, everything works fine if I put:
        >
        > var myDataSource = new YAHOO.util.DataSource(
        > [
        > [1","-","-","-","-","-","-"],["2","-","-","-","-","-","-"]
        > ],
        > {responseType: YAHOO.util.DataSource.TYPE_JSARRAY}
        > );
        >
        > Can anyone tell me the solution? I need to dynamically place the
        > values in the array at the loading time, I can't use a datasource
        > with previously set values.
        >
        > Thank you in advance!
        >
        >
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        > --
        > No virus found in this incoming message.
        > Checked by AVG Free Edition.
        > Version: 7.5.516 / Virus Database: 269.19.16/1250 - Release Date:
        > 29/01/2008 22:20
        >
        >
      • Radu
        Thanks a lot for your explanation. As soon as I parsed the string into an array all worked well.
        Message 3 of 3 , Jan 31, 2008
          Thanks a lot for your explanation. As soon as I parsed the string
          into an array all worked well.
        Your message has been successfully submitted and would be delivered to recipients shortly.