Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox object error

Status
Not open for further replies.

ppuxley

Technical User
Mar 24, 2002
3
US
I am a new VBscript programmer constructing a form and VBscript in a web page.

Here is part of a simple form:

<form name=&quot;whichOptions&quot;>
Perform which checks?<br>
<input type=&quot;checkbox&quot; name=&quot;chkPropMode&quot;>Prop mode<br>
<input type=&quot;checkbox&quot; name=&quot;chkDiffMode&quot;>Diff mode<br>
<input type=&quot;checkbox&quot; name=&quot;chkAppleMode&quot;>Apple mode<br>
<input type=&quot;button&quot; name=&quot;verify2&quot; value=&quot;test prog&quot;><br>
<input type=&quot;reset&quot; value=&quot;clear selections&quot;>
</form>

And here is the script:

sub verify2_OnClick

document.write(whichOptions.ChkPropMode.checked)
document.write(whichOptions.ChkDiffMode.checked)
document.write(whichOptions.ChkAppleMode.checked)

end sub

When I run it (or versions in which I test the various checkbox statuses), the correct status of the first checkbox is written but then I get:

Error: doesn't support this property or method 'whichOptions'

Why?

Thanks in advance
Phil
 
I think the problem you are encountering is due to the fact that document.write() is not really supposed to be used after the page has loaded.

You didn't show a document.open call, but I have to assume from trying a skeletal page incorporating your code above, IE is going ahead and assumes an implied open.

This clears the current document, and in the process throws away all current variables and the elements on the page.

So your first write will work, but the next one finds that there isn't anything named whichOptions anymore.

If you are simply trying to debug your code or something you might try MsgBox for displaying values instead.
 
Thanks dilettante.

Now I assign the checkbox status to variables before doing the document.write and everyone is happy.

Phil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top