Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Object Within Form has no Properties

    I've declared a form:
    <FORM action="#" name="Selections">
    and I remember to close it!

    And I've place some checkboxes within the form:
    <INPUT type=checkbox name="AudioChoices" value="1"/>

    And I've written a bit of JavaScript:
    <script type="text/javascript">
    var df=document.forms;
    var vCollection = document.getElementsByName('AudioChoices');
    var CheckedItems;
    function PlaySelected()
    {
    var First = true;
    for (var i = 1; i < vCollection.length; i++){
    if (df["Selections"][i].checked) {
    if (First) {
    CheckedItems = df["Selections"][i].value;
    First = false;
    }
    else{
    CheckedItems = CheckedItems + ", " + df["Selections"][i].value;
    }
    }
    }
    getMedia('ATC', '24-Jan-2005', CheckedItems, 'WM,RM'); }
    </script>

    The idea is that the user makes some selections and then the JavaScript takes action on the selections made. The problem is this:
    Error: df.Selections[i] has no properties

    Any ideas on why?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    <script type="text/javascript">
    function PlaySelected()
    {
      var vCollection = document.forms['Selections'].elements['AudioChoices'];
      var CheckedItems = '';
      for (var i = 0; i < vCollection.length; i++){
        if (vCollection[i].checked) {
          if (CheckedItems == '') {
            CheckedItems = vCollection[i].value;
          }
          else{
           CheckedItems += ", " + vCollection[i].value;
          }
        }
      }
      getMedia('ATC', '24-Jan-2005', CheckedItems, 'WM,RM'); 
    }
    </script>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Any ideas on why?
    you misstyped the element

    document.forms[0].elements['Selections'][i]
    if the checked radio collection has name "Selections"
    or
    document.forms['Selections'].elements['AudioChoices'][i];
    if form as called Selections and tyhe radios are AudioChoices
    Last edited by Kor; 01-26-2005 at 11:00 AM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •