Link to home
Start Free TrialLog in
Avatar of kasperEH
kasperEHFlag for Denmark

asked on

Can't access domino field in javascript

I am trying to access a domino field in javascript, but it's not working, I keep getting the error in Internet Explorer 7 that it's "null or not an object". I tried to make a simple example where I just display the value (see code below).  I have checked the "Create HTML for all fields" option and even put in Edit mode to check if that was the problem.
<script language="Javascript" type="text/javascript">
document.write(document.forms[0].CourseType.value)
</script>

Open in new window

Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

1) What type of field is CourseType? It might not have a Value property. Start with just a text-field.
2) Why document.write()? It is evaluated directly when the page is loaded, and at that time the value of CourseType is probably empty. Better use the alert() functuon, or add some button with an alert.
Make sure that the field has the Id set on the HTML properties tab.  The Id should be the same as the field's name.
SOLUTION
Avatar of CRAK
CRAK
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
(correction: view source)
Avatar of kasperEH

ASKER

To sjef_bosman: CourseType is a dialog list field. The documents are created in the Notes client and viewed (by most users) in the browser.
As the document has already been saved, I think the field should be there when document.write is evaluated.
To Bill_Hanson: I have set the id now on the HTML properties tab and it still doesn't work.
To CRAK: The field looks like this in the HTML: <input name="CourseType" type="hidden" value="Intro programme">
But it appears after my JavaScript, so this might be the problem. But why is it like this when the CourseType field is at the top of the form and the JavaScript code in the bottom?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
All of you, thanks for your trying to help me with this problem. I have now chosen a different solution, where I use Computed Text instead of JavaScript.

I still find it strange that passthru HTML with JavaScript placed at the bottom of the form appears before a hidden field placed at the top of the form, but never mind.