...

View Full Version : Using forms in JavaScript



isleshocky77
01-14-2003, 01:08 AM
I tried doing this completely from JavaScript w/o html. We'll say for my purposes.. this is the way I need it done. Any suggestions how to declare the form w/o html <form> tags?


<html>
<script language="javascript">
function test() {
document.form[0].action="from.asp";
document.form[0].method="post";
document.form[0].name="Stephen";
document.form[0].age=17;
doucment.form[0].submit();
}
</script>
<a href="javascript:test();">Hello</a>
</html>

this returns the error:

Error: 'document.form.0' is null or not an object

CRASH_OVERRIDE
01-14-2003, 01:43 AM
If my sources (http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/obj_document.asp) are correct, the collection should be

document.forms[0]

not

document.form[0]

MrDoubtFire
01-14-2003, 03:00 AM
I concur, forms, not form.

Roy Sinclair
01-14-2003, 08:54 PM
You aren't going to do it without <form> tags on your page, if you didn't want to use the POST method you could simulate it but POST is going to require a form. That shouldn't be a problem though because you can use hidden fields on the form instead of visible fields so your whole form is hidden from the user's view.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum