[thelist] simple but baffling JS problem...

Erik Mattheis gozz at gozz.com
Mon Feb 5 07:48:37 CST 2001


Continuing from Matt's reply explaining how to pass a checkbox object 
to a function, you're going to get another error something like 
'parent.topFrame.document.form1.propName has no properties' or 
"Object Expected' - try this:

onclick="updateValue(this);"


function updateValue(propName) {
	var hideyElement = eval('parent.topFrame.document.form1.' + 
propName.name);
	hideyElement.value = propName.checked;
	}

This will also make your script aware if the user is un-checking a 
box they had previously checked.


>I'm trying to work out a javascript solution.
>
>I have a series of pages that display vacation properties. I want a user to
>be able to browse those pages, and check a checkbox for each property that
>they would like more information about...
>
>THEN, if/when the user visits the inquiry form, the properties that they
>checked are displayed on the form, AND written into hidden input values to
>be passed to the form handler script.
>
>My approach avoids the use of cookies. I have 2 frames, one for the property
>pages and one for the stored values. My function...
>
><script language="JavaScript">
><!--
>function updateValue(propName) {
>	var hidey = 'parent.topFrame.document.form1';
>	hidey.propName.value="true";
>}
>//-->
></script>
>
>is on the same page as the checkboxes, which look like this...
>
><input type="checkbox" name="sugarcove" onclick="updateValue(self.name);">
>
>
>Naturally, the other form (which is just a series of inputs designed to do
>nothing more than store the values true pr false depending on which
>checkboxes are selected) is in the other frame.
>
>THE PROBLEM...
>When you click the checkbox, an error is generated that says 'propName is
>null or not an object'. But, as far as I can tell...it IS TOO an object!
>
>I suspect this is because of how I try to access the value...from one framed
>page, up to parent, and back down into the other framed page.
>
>But what's the solution?
>
>thanks,
>John Corry
>
>
>---------------------------------------
>For unsubscribe and other options, including
>the Tip Harvester and archive of TheList go to:
>http://lists.evolt.org Workers of the Web, evolt !

-- 
- Erik Mattheis
http://gozz.com/
(612) 827 3963




More information about the thelist mailing list