Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-25-2005, 03:02 AM   PM User | #1
cweaver
New Coder

 
Join Date: Dec 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
cweaver is an unknown quantity at this point
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?
cweaver is offline   Reply With Quote
Old 01-26-2005, 02:10 AM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
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
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 01-26-2005, 09:56 AM   PM User | #3
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Quote:
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
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Last edited by Kor; 01-26-2005 at 10:00 AM..
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:05 PM.


Advertisement
Log in to turn off these ads.