Web Analytics Made Easy -
StatCounter simple split string problem - CodingForum

Announcement

Collapse
No announcement yet.

simple split string problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • simple split string problem

    Can anyone tell me why the following gives me the error "Object doesnt support this property or method"? Im sure its something really simple, I just cant see it.

    Code:
    rota_name_array = array_string.split(",");
    alert(rota_name_array.length);
    btw - array_string = "a,b,c"

  • #2
    Hard to tell without seeing complete code, better yet link to the page in question...
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

    Comment


    • #3
      Because you are trying to split array_string before it is defined?
      Who knows, as Vladdy said, need more code...

      BTW: This works:
      <script>
      array_string = "a,b,c"
      rota_name_array = array_string.split(",");
      alert(rota_name_array.length);
      alert(rota_name_array[1].length)
      </script>

      .....Willy

      Comment


      • #4
        Vladdy, Here is the code and the link is: www.heaps21.f2s.com/add_rota_type1.php

        The code posted before is literally all I am trying to do at the moment though so there isnt much more to see there.

        Ita all there for you anyway, cheers.
        Attached Files

        Comment


        • #5
          Use correct way to access document objects:
          http://www.w3.org/TR/2000/REC-DOM-Le...1113/core.html
          http://www.w3.org/TR/DOM-Level-2-HTML/html.html

          myForm = document.getElementById('formID');
          or
          myForm = document.forms['formName'];

          elementValue = myForm.elements['elementName'].value;

          Also avoid using with() until you are absolutely sure that you know what you are doing.
          Last edited by Vladdy; Feb 16, 2004, 01:22 PM.
          Vladdy | KL
          "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

          Comment


          • #6
            As I said. You are not defining the array_string!
            Where's the value being passed? It's not, it's undefined....

            Try this:

            rota_name_array = array_string.value.split(",");

            .....Willy

            Comment


            • #7
              ah yes thats much better thanks, but what is wrong with 'with' - I only used is coz i saw it in a script online somewhere :-)

              Comment

              Working...
              X