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

kasperEHAsked:
Who is Participating?
 
Sjef BosmanGroupware ConsultantCommented:
So it's not a text field. A dialog list is converted into a Select in HTML. The Select doesn't have a value property. Instead, it has the selectedIndex property. Here are some interesting examples:

http://www.javascriptkit.com/jsref/select.shtml

Although, the HTML line you added doesn't really show that it's a dialog list. CourseType is a hidden field, with a value. Hmmm, can you explain how this is supposed to work? What's the real field??

And yes, sequence matters. If your JavaScript is added at the top, in the HEAD section probably, the line gets evaluated when the page is loaded. If you need the code to be executed elsewhere, you have to include the JavaScript code in your page manually, with passthru HTML enabled. Select the HTML in your page, then click Text/Passthru HTML.
0
 
Sjef BosmanGroupware ConsultantCommented:
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.
0
 
Bill-HansonCommented:
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.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
CRAKCommented:
Take a look at the output in HTML (View Design) and search for the field name. It's easier to work from there.
Text fields have a value. Radio buttons, checkboxes, listboxes etc. need to be addressed differently. E.g: do you get <SELECT...> instead of <INPUT...>?
0
 
CRAKCommented:
(correction: view source)
0
 
kasperEHAuthor Commented:
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?
0
 
kasperEHAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.