/    Sign up×
Community /Pin to ProfileBookmark

"document.[formname].submit()" not working?

Hi- I have a simple, yet frustrating problem.
About a year ago or so, I created a simple page
using a form and links that submit the page.
Additionally, I have functions on it that fill some
input fields with values.

Now none of them are working anymore:
– the request “document.formname.submit();”
generates the error “Object doesn’t support
function or method”.
– the “document.formname.fieldname.value= ‘xxx’;”
generates the error “Is NULL or not an object”.

I am sure it’s something really simple and I am
just too blind to find it (overworked! ? ) but…
yea- it’s discouraging.

Any suggestions?

Thanks!

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@WebskaterJan 17.2003 — Post the code.
Copy linkTweet thisAlerts:
@ceoofaepauthorJan 17.2003 — 

the code:
-------------


function fillvalue(fieldname)

{

switch(fieldname)

{

case "name":

document.testform.name.value = "Some Value";

break;

case "plz":

document.testform.plz.value = "Some Value";

break;

}

}
-------------


and the html code calling / receiving it:
-------------


<FORM action="test.asp" method=POST name="testform">

<input type="name" size="40" maxlength="100" value="">

<INPUT type="button" value="Fill Values" name="NameValue" style="width:90px" width="90px" onclick="Javascript:fillvalue('name');">

</FORM>
-------------


All this is in the file "test.asp", by the way.

Thanks again
Copy linkTweet thisAlerts:
@WebskaterJan 17.2003 — This expression in your code:

document.testform.name.value = "Some Value";

is expecting to find a control (button, text box whatever) within the form called "testform" that is called (or named) "name".

The input control you have on your form is:

<input type="name" size="40" maxlength="100" value="">

This has a type attribute of "name" but is not named. To get your code to work it should be:

<input type="text" name="name" size="40" maxlength="100" value="">

Naming controls or ojects "name" is not a good idea.
Copy linkTweet thisAlerts:
@WebskaterJan 17.2003 — Oh, by the way, sorry if that is too simple and you have posted generic code.
Copy linkTweet thisAlerts:
@ceoofaepauthorJan 17.2003 — ::hides under a rock::

Thank you. That was it. I should be shot.

The problem is, I am working on two things

at once. That's why I posted it as generic

code- to include both codes in one posting

on here.

One is a private project (the one where the

"document.formname.submit();" thing is

not working, the other one where the "send

values to an input field" was not working).

The latter is solved now. it was code I

"inherited" from a coworker of mine who

worked on it before so I overread that part,

not paying attention to it being "type="

instead of "name=".

The other problem still remains. This is the

code from it (I cut off the "script language=

javascript", though, because that is not relevant

and other functions work, just not the submit

one.
---


function dologin(loginstep)

{

document.mdb.dologin.value = loginstep;

document.mdb.submit();

}
---


<form name="mdb" action="mdb.asp" method="post">

<input type="hidden" name="dologin" value="">

<a href="Javascript:dologin('2');">ok</A>

</form>
---


this gives me the "the object doesnt support the

attribute or method" for the row in which the submit

is triggered... but the form is definitely called "mdb"

(I checked spelling and upper / lower case and all)

Any idea?
Copy linkTweet thisAlerts:
@ceoofaepauthorJan 17.2003 — by now I found out that it only seems to happen when the code is in that asp-file (mdb.asp)... it doesn't happen when I paste just the code into an empty HTML file and try it out.

could it be that there are restrictions of some sort on the server that have been changed / added since the last time I looked at the files (when they were still working)?

::is confused::
Copy linkTweet thisAlerts:
@WebskaterJan 17.2003 — I appreciate this is extremely unlikely to be the cause of the problem but 'mdb' is the file suffix for a Microsoft Access database and with asp you are in the Microsoft world. Why this would upset a javascript function is a mystery but you never know. Have you tried calling your form something other than mdb?
Copy linkTweet thisAlerts:
@ceoofaepauthorJan 17.2003 — ...not yet- and I won't know until monday because I only have those files running at work and I'm home now. But I will definitely try to see if that helps at all.

The thing is, if I recall this right, that about a year ago when I first sat down to create the file (it's a personal project for a media database- to store the info about all the cds I have) it worked... but back then we had a different server setup and I don't know if that might be the reason (mind you- the file works well- only that one javascript function doesn't). It's all quite confusing.

The confusing part is that the Javascript is running on the client so the server would probably not "mind" anything concerning it- let alone be able to interfere with it... and I even set my browser's internet security setting to low.

One thing I just remembered- the last time I looked at the files it was with MSIE 5.0, now it's 6.0... but I programmed it so it also works in NS 4.72... and it doesn't work there anymore, either.

Could it be because the directory in which the file is stored is not declared as a web-folder on the IIS?

This is starting to annoy me ? I just want it to work ?

I'll probably port it all to php & mySQL at some point, anyways... I am not a big fan of M$.

So long~

Regards.
×

Success!

Help @ceoofaep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...