View Full Version : Problem calling function with ASP

Nov 29th, 2005, 12:32 PM
I'm having problems with ina page of mine. The page checks a database to see whether the user has a value in a field and if they do then a hidden variable in a form is set to this value. However, if they don't, the form displays a drop down box for them to accept a value. The problem arrises with a bit of form validation that is being run on the page. The button to submit the form is disabled unless the user selects an option from the drop down, once they've done this the button not only enables but also changes its value. When the user already has a value in the DB then the button must be enabled and its value changed. I've tried doing this by calling a function in the onLoad method but this isn't working.

Here is my code: (ASP in Vbscript)

<script language="JavaScript">
function noForumID() {
if (document.getElementById("talent_forum_id").selectedIndex == 0) {
document.getElementById("tomanager").disabled = true;
document.getElementById("tomanager").value = "Select a forum member"
} else {
document.getElementById("tomanager").disabled = false;
document.getElementById("tomanager").value = "Submit to " + document.getElementById("talent_forum_id").options(document.getElementById("talent_forum_id").selectedIndex).text;
function forumID() {
document.getElementById("tomanager").disabled = false;
document.getElementById("tomanager").value = "Submit to " + document.getElementById("talent_forum_id").value;
<body ... <%if(employee_details("forumMemberID")<>"") then %>onLoad="forumID()"<%end if%> >


<%if(employee_details("forumMemberID")<>"") then
%><br/>Your talent forum member has been identified as <b><%=employee_details("forumMemberID")%></b>
<input type="hidden" name="talent_forum_id" id="talent_forum_id" value="<%=employee_details("forumMemberID")%>" />
<% else %>
<select name="talent_forum_id" id="talent_forum_id">
<option value="">Select the appropiate forum member</option>
for each x in talentForumMember
response.write("<option value=""" & x & """>" & x & "</option>")
<%end if%>

<script language="javascript" >
document.getElementById("talent_forum_id").onchange = noForumID();
<input type="button" value="Submit" name="tomanager" id="tomanager" onclick="saveAndLock()" disabled="true">
<input type="hidden" name="sendtohr" value="false" id="sendtohr" />
<script language="javascript">
function saveAndLock() {
document.getElementById("sendtohr").value = "true";

I get an error in IE saying "'document.getElementById(...)' is null or not an object" Any ideas why?

Nov 29th, 2005, 01:15 PM
I get an error in IE saying "'document.getElementById(...)' is null or not an object" Any ideas why?


Which document.getElementById(...) is causing the error. You have quite a few. Also I do not see any html code. So we don't know which tags are "Id".

Usually when I get this error I was spelling the Id name different in one location are another. So the Id that you declare in the tag has to match the id in the function.

Nov 29th, 2005, 01:33 PM
Hi Joe,

Ran the same page in FF and it gave me a better answer:

Error: document.getElementById("tomanager") has no properties
Source File: Line: 21

Though the line 21 doesn't help that much because of the addtional code which mucks up the line numbers (i believe)
From what I can tell all mentions of 'tomanager' are spelt correctly.

Nov 29th, 2005, 01:38 PM
Which html tag are you IDing with "tomanager"?

Nov 29th, 2005, 04:47 PM
Errm, believe all of the IDing tags for 'tomanager' are iding an html tag.

Nov 29th, 2005, 05:17 PM
Errm, believe all of the IDing tags for 'tomanager' are iding an html tag.

But which html tag have you id with "tomanager"? Is it <frame>, <img>, <a>, etc.

Not all tags have properties not all the ones that do have properties have a disable property. Not all html tags have the same set of properties.

Never mind, I guess I have been up to long, I see them now in your code. I'm too tired right now to think straight. I hope someone else can help you before I get up.