473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

parameters not entering function?

I keep getting a runtime error stating that this
document.adddealer.dealertoadd.value = dealer; is null or not an
object. I've rewritten the Function everyway I could think of, and
couldn't find any thread examples of my problem.

Here is my Function;

<Script language="JavaScript">
<!--//hide
function AddDealer(dealer) {
document.adddealer.dealertoadd.value = dealer;
document.adddealer.submit();

}
//-->
</script>

This calls the Function;

<input type="button" value="Make This My Dealer"
onClick="AddDealer('<%=(iwDealerCode(x))%>');" name="button">

When the code breaks and I bring up Microsoft Debugger it shows a
value in the parameter. I would appreciate any pointers on this.

Regards,

Andrew
Jul 20 '05 #1
6 2015
In article <1c**************************@posting.google.com >,
we*******@dakotacollectibles.com enlightened us with...
I keep getting a runtime error stating that this
document.adddealer.dealertoadd.value = dealer; is null or not an
object. I've rewritten the Function everyway I could think of, and
couldn't find any thread examples of my problem.

Here is my Function;

<Script language="JavaScript">
<!--//hide
function AddDealer(dealer) {
document.adddealer.dealertoadd.value = dealer;
Where in the code is the text input with the name set to dealertoadd?
I see one with a name of button. But not
name="dealertoadd"
which is what better be there for the code above to run. :)
<input type="button" value="Make This My Dealer"
onClick="AddDealer('<%=(iwDealerCode(x))%>');" name="button">


I'm thinking you named this wrong.

--
~kaeli~
Suicide is the most sincere form of self-criticism.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
Andrew wrote on 25 Nov 2003:

<snip>
<Script language="JavaScript">
You don't need to use the language attribute, but you *must* use the
type attribute. Change the above to:

<SCRIPT type="text/javascript">
<!--//hide
There is no need to hide SCRIPT element contents with SGML comments.
function AddDealer(dealer) {
document.adddealer.dealertoadd.value = dealer;
You don't say it, but it's clear that 'adddealer' is a form and
'dealertoadd' is a form control. It is better to use this syntax (it
works across more browsers):

document.forms['adddealer'].elements['dealertoadd'].value = dealer;

May I also suggest that you use hyphens (-), underscores (_), or
capitalisation to make your identifiers more readable. Be aware that
if you use hyphens, you must use the collection syntax (above) to
access the element, or it will be interpreted as the subtraction
operator.
document.adddealer.submit();
This can be changed, likewise:

document.forms['adddealer'].submit();
}
//-->
You can remove that.
</script>

This calls the Function;

<input type="button" value="Make This My Dealer"
onClick="AddDealer('<%=(iwDealerCode(x))%>');" name="button">


Please don't show server-side elements of your script. They mean
nothing to us. Instead, indicate what /would/ be there after an
interpreter has parsed it.

Couldn't you have found a better name for your button other than
'button'? Identifiers should have meaningful names. Something like
'button' can lead to the terrible habit of naming everything
'button1', 'button2', 'button3', etc.

The only other things to check (as you didn't show them here), is
that a form exists with the name, 'adddealer', and a control exists
with the name, 'dealertoadd'.

Hope that helps,
Mike

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #3
Thanks for the enriching reply.

I've changed my code as you suggested and am still getting the same
error. I have a hidden form that I forgot to add in my origial post.
This is what I have now.

<SCRIPT type="text/javascript">

function AddDealer(dealer) {
document.forms['adddealer'].elements['dealertoadd'].value = dealer;
document.forms['adddealer'].submit();
}
</SCRIPT>

<form name="adddealer" action="register2.asp" method="POST">

<input type="hidden" name="dealertoadd" value="">
<input type="button" value="Make This My Dealer"
onClick="AddDealer(2479);" name="CustDealer">

Thanks again!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4
Lee
Andrew said:

I keep getting a runtime error stating that this
document.adddealer.dealertoadd.value = dealer; is null or not an
object.


When asking for help with an error message stating that some
object doesn't exist, you should include enough code to show
us that it actually does exist.

Jul 20 '05 #5
A Lexiewa wrote on 25 Nov 2003:
Thanks for the enriching reply.

I've changed my code as you suggested and am still getting the
same error. I have a hidden form that I forgot to add in my
origial post. This is what I have now.


<snipped code>

That's strange, because what you showed* worked in both IE 6 and
Opera 7.22. Is the error /exactly/ the same as before, or has it
changed?

A common problem that people seem to run into is using method names
as control names - the most common one is calling a submit button,
'submit'. If there is more to this script than you're showing us,
check that none of your controls use Form object method names.
However, if what you showed in your reply is verbatim, then frankly,
I'm stumped.

Mike
* I changed part of your code for testing purposes, namely the action
and method attribute values, but everything else was the same.

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #6
Lee
A Lexiewa said:

Thanks for the enriching reply.

I've changed my code as you suggested and am still getting the same
error. I have a hidden form that I forgot to add in my origial post.
This is what I have now.

<SCRIPT type="text/javascript">

function AddDealer(dealer) {
document.forms['adddealer'].elements['dealertoadd'].value = dealer;
document.forms['adddealer'].submit();
}
</SCRIPT>

<form name="adddealer" action="register2.asp" method="POST">

<input type="hidden" name="dealertoadd" value="">
<input type="button" value="Make This My Dealer"
onClick="AddDealer(2479);" name="CustDealer">

Thanks again!


When I add just enough HTML to make your posted code functional,
it works without any error. The problems seems to be in some
part of the page that you haven't shown us:
<html>
<body>
<SCRIPT type="text/javascript">

function AddDealer(dealer) {
document.forms['adddealer'].elements['dealertoadd'].value = dealer;
document.forms['adddealer'].submit();
}
</SCRIPT>

<form name="adddealer" action="register2.asp" method="POST">
<input type="hidden" name="dealertoadd" value="">
<input type="button" value="Make This My Dealer"
onClick="AddDealer(2479);" name="CustDealer">
</form>
</body>
</html>

Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
7
by: What-a-Tool | last post by:
Have no problem getting my select queries to work using this method: strSQL = "SELECT tblUI.IPAdd FROM tblUI WHERE (tblUI.IPAdd =?)" arSPrm = Array(strRemHst) Set rst = cmd.Execute(,arSPrm)...
0
by: murl | last post by:
I have created a crystal report using crystal9.0, that is linked to a stored procedure in sql2k which requires 2 parameters to be met, a beggining date(smalldatetime) and a...
0
by: murl | last post by:
I have built a crystal report using crystal9.0 that is linked to a stored procedure built in sql2k, which requires 2 parameters beginningdate(smalldatetime),and endingdate(smalldatetime). When the...
2
by: | last post by:
When I start the application by entering param1 in the url, I want to be redirected to webform1, and when I start the application by entering param2 in the url I want to be redirected to...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
10
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication...
0
by: Xah Lee | last post by:
In this article, i explain how the use of bit masks is a hack in many imperative languages. Often, a function will need to take many True/False parameters. For example, suppose i have a function...
3
by: bockyweez | last post by:
Let me start off by stating that I use Access, but have limited knowledge in SQL... I do have a good understanding of programming (C++) though, so I can follow the logic behind it. But I use dirty...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.