Submit forms with 'multiple submitbuttons' with javascript

K

kjex

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!?
 
L

lallous

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top