HighDots Forums  

Submit forms with 'multiple submitbuttons' with javascript

Javascript JavaScript language (comp.lang.javascript)


Discuss Submit forms with 'multiple submitbuttons' with javascript in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kjex
 
Posts: n/a

Default Submit forms with 'multiple submitbuttons' with javascript - 02-05-2004 , 08:27 AM






I'm rewriting a webshop where all the "ugly submitbuttons" are changed
with more complexed and nice looking <a href="#" onclick="">'s

So here is the case, in the form there are several submitbuttons that
makes the backend javaengine deside what do do;

<input type=submit name="More<%= question.getAttributeKey().toString()
%>" value="<isa:translate key="marketing.jsp.ChangeFields"/>">
<input type=text name="SaveMktProfile" value="<isa:translate
key="b2c.marketing.profile.saveButton"/>" class="FancyButton">
<input type=text name="CancelMktProfile" value="<isa:translate
key="marketing.jsp.Cancel"/>" class="FancyButton">

(makes the buttons; more, save and cancel)

How can I submit the form with javascript?
I tried make a dummy field <input type=hidden name="dummy"
value="xxx"> and call the submitscript:

<a href="javascript:Submitscript('SaveMktProfile')">

<script>
function submitscript(action){
document.form[1].dummy.name=action;
documen.form[1].submit();
}
</script>

but this don't work..

Have I just misunderstand the whole thing!?

Reply With Quote
  #2  
Old   
lallous
 
Posts: n/a

Default Re: Submit forms with 'multiple submitbuttons' with javascript - 02-05-2004 , 08:55 AM






Hello,

You can submit as: theForm.submit()

If you want to know what to do on submit, add a hidden field and change its
value to denote what action to be done as:

<input type='hidden' name='whattodo' value='x'>
<script>
function submitDoThis(theform)
{
theform.whattodo.value = 'dothis';
theform.submit();
}

function submitDoThat(theform)
{
theform.whattodo.value = 'dothat';
theform.submit();
}
</script>

Later in your server page you can check the variable 'whattodo' and decide
what to do based on its value.

HTH,
Elias
"kjex" <art_psimon (AT) hotmail (DOT) com> wrote

Quote:
I'm rewriting a webshop where all the "ugly submitbuttons" are changed
with more complexed and nice looking <a href="#" onclick="">'s

So here is the case, in the form there are several submitbuttons that
makes the backend javaengine deside what do do;

input type=submit name="More<%= question.getAttributeKey().toString()
%>" value="<isa:translate key="marketing.jsp.ChangeFields"/>"
input type=text name="SaveMktProfile" value="<isa:translate
key="b2c.marketing.profile.saveButton"/>" class="FancyButton"
input type=text name="CancelMktProfile" value="<isa:translate
key="marketing.jsp.Cancel"/>" class="FancyButton"

(makes the buttons; more, save and cancel)

How can I submit the form with javascript?
I tried make a dummy field <input type=hidden name="dummy"
value="xxx"> and call the submitscript:

a href="javascript:Submitscript('SaveMktProfile')"

script
function submitscript(action){
document.form[1].dummy.name=action;
documen.form[1].submit();
}
/script

but this don't work..

Have I just misunderstand the whole thing!?



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.