Home: Other Programming Languages: Javascript:
submit/reset problem



parham_m_s
journeyman

May 15, 2001, 1:36 PM


Views: 13252
submit/reset problem

i have forms around my script which have different form names. I am submitting and resetting my forms through javascript.

here's the submitting part of it ('mainform' is the name of the form), i did it this way so i can change the name of the form easily:

Code
<A HREF="javascript:form_submit('mainform')"><IMG SRC="submit.gif" BORDER=0></A>

and here's the submit javascript part of it:

Code
function form_submit(selected_form) { 
document.selected_form.submit();
}

i keep getting an error, but i don't know why. I'm not completely familiar with javascript, so passing information is very new to me. Any help is appreciated, thank you.



parham_m_s
journeyman

May 17, 2001, 5:07 PM


Views: 13244
Re: submit/reset problem

anyone please, i'm still kinda stuck on this. I've shortened the code if anyone didn't understand. The form won't submit or reset still.

Code
<HTML> 
<HEAD>
<TITLE>test</TITLE>
</HEAD>
<BODY>
<script language="JavaScript">

</script>
<FORM NAME="mainform" ACTION="http://www.webcrawler.com" METHOD=GET>
<INPUT TYPE="text" VALUE="something">
<A HREF="javascript:form_submit('mainform')">submit</A> <A HREF="javascript:form_reset('mainform')">reset</A>
</FORM>
</BODY>
</HTML>



freddo
User

May 22, 2001, 10:45 AM


Views: 13236
Re: submit/reset problem

Hello Param,

here's my try at it:

Code
<html> 
<body>

<form name="mainform" action="test.html">
<A HREF="javascript:form_submit('mainform')">Test2</A>
</form>

<script language="JavaScript">
function form_submit(selected_form) {
document.forms[selected_form].submit();
}
</script>
</body>
</html>

you can find more info on javascript here.

see you
freddo

;---
Real programmers don't eat cache.