[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Microsoft JScript runtime error: 'this.form.cboContacts' is null or not an object

Posted on 2004-04-20
6
Medium Priority
?
2,086 Views
Last Modified: 2007-12-19
Hello,

I'm having a spot of bother with an object on my webpage which generates the following error

"Microsoft JScript runtime error: 'this.form.cboContacts' is null or not an object"

I'm developing this in C# and have added Javascript to a hyperlink. In HTML, the link looks like this:

<a id="lnkForgotPassword" title="Click here to receive an email reminder of your password." class="label" onclick="javascript:if(this.form.cboContacts.value != 0) {if(confirm('Proceed with password reminder request?')==false) return false;}" href="javascript:__doPostBack('lnkForgotPassword','')" style="width:184px;">Forgotten your password?</a>

Now the object in question, cboContacts does exist. In HTML its a SELECT/OPTION as follows:

<select name="cboContacts" id="cboContacts" class="label" OnFocus="alert(this.name)" style="height:16px;width:256px;">
      <option selected="selected" value="0"></option>
      <option value="9999">~*~ Admin ~*~</option>
      <option value="1">Surname1, FirstName1</option>
      <option value="2">Surname2, FirstName2</option>
.....
</select>

I added the OnFocus event to see if the object was recognised, and obviously it gave a popup message containing "cboContacts".

I want the hyperlink to test if a value has been selected (other than the empty first option), and if one has to question the user if he wished to continue to receive the email reminder. The href of the hyperlink executes codebehind code which queries the database to obtain the selected users email address and posts them their email.

Why is it failing and how do I fix this?

regards

Brian
0
Comment
Question by:obyapka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 10867778
replace  this.form.cboContacts.value  with  document.getElementById('cboContacts').value
0
 
LVL 7

Expert Comment

by:searlas
ID: 10867800
The reason why is was failing is because anchors are not form objects, and so this.form is not a valid reference in your javascript (i.e. this.form is undefined).
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10867845
Check this:

<a id="lnkForgotPassword" title="Click here to receive an email reminder of your password." class="label" onclick="if(document.forms[0].cboContacts.value != 0) {if(confirm('Proceed with password reminder request?')==false) return false;}" href="javascript:__doPostBack('lnkForgotPassword','')" style="width:184px;">Forgotten your password?</a>


0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 63

Accepted Solution

by:
Zvonko earned 1200 total points
ID: 10867865
Sorry, the first if condition lets pass the onClick without confirm()

Check this:

<a id="lnkForgotPassword" title="Click here to receive an email reminder of your password." class="label" onclick="if(document.forms[0].cboContacts.selectedIndex>0) {if(confirm('Proceed with password reminder request?')==false) return false;} else return false;" href="javascript:__doPostBack('lnkForgotPassword','')" style="width:184px;">Forgotten your password?</a>


0
 
LVL 1

Author Comment

by:obyapka
ID: 10868082
I just changed the last "else return false;" to the following:

{alert('Select a user name from the list.');return false;}

and it now works a treat.

Many thanks for everyones assistance.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10868100
Thanks for points and feedback.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question