...

View Full Version : Object Within Form has no Properties



cweaver
01-25-2005, 04:02 AM
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?

glenngv
01-26-2005, 03:10 AM
<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>

Kor
01-26-2005, 10:56 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum