View Full Version : Banging my Head!

08-04-2006, 09:04 PM
function doSubmit()
with (document.theForm)
action = "https://www.mysite.com/";
method = "post";

<form name="theForm" method="POST" action="https://www.mysite.com/">
... inputs here...
... <input type="button" onClick="doSubmit();" value="submit me">

The form is a bit more complicated but you get the idea. Simple. straight forward... or at least it should be.

when it gets to the "submit();" part i get this

Line: 100
Char: 6
Error: Object doesn't support this property or method
Code: 0
URL: myurl

Any help on this would be much appreciated.

I'm running IE6 with SP2 and all updates AFAIK

Thanks in advance.

08-05-2006, 11:53 AM
with() is slow. I don't recommend its use at all. (http://www.dynamicsitesolutions.com/demos/js_with_speed_test.html)

What's the point of the function anyway? Why don't you just make the <input> be type="submit" instead of type="button"?

Keep in mind that some Internet users use a browser that doesn't have JavaScript enabled. (http://www.thecounter.com/stats/2006/July/javas.php)

The Importance of Degrading Gracefully (http://weblog.burningbird.net/archives/2005/03/25/the-importance-of-degrading-gracefully/)
Perpetuating the myths of JavaScript degradation. (http://domscripting.com/blog/display.php/25)

08-05-2006, 04:06 PM
with() is slow. I don't recommend its use at all.
Agree! And it's somehow hard to handle, as you must remember all the time which is the associated root object. And, most important, you may not use another new object as root/associated inside.

Use rather the self reference this

function doSomething(f){
... now f replaces the form object

function doAnotherthing(f){
<form onsomeevent="doSomething(this)">
<someformelement onsomeevent="doAnotherthing(this.form)">

08-06-2006, 04:38 AM
All your suggestions are valid but they are not the exact solution to the main problem.

The reason submit() is not a valid method is because one of the form fields is named "submit" thus confusing the browser to think that you are referencing that field and not the form method submit(). If you rename that field to something else, the error will go away.

08-07-2006, 02:42 PM
You sir, are the winner! Later that evening I noticed that the button was indeed named "submit" and changed it. Fixing the problem. Sometimes it amazes me how I can still miss the little things. Thanks for all the suggestions folks.