Submit forms with 'multiple submitbuttons' with javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kjex

    Submit forms with 'multiple submitbuttons' with javascript

    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.getAtt ributeKey().toS tring()
    %>" value="<isa:tra nslate key="marketing. jsp.ChangeField s"/>">
    <input type=text name="SaveMktPr ofile" value="<isa:tra nslate
    key="b2c.market ing.profile.sav eButton"/>" class="FancyBut ton">
    <input type=text name="CancelMkt Profile" value="<isa:tra nslate
    key="marketing. jsp.Cancel"/>" class="FancyBut ton">

    (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="javascrip t:Submitscript( 'SaveMktProfile ')">

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

    but this don't work..

    Have I just misunderstand the whole thing!?
  • lallous

    #2
    Re: Submit forms with 'multiple submitbuttons' with javascript

    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(th eform)
    {
    theform.whattod o.value = 'dothis';
    theform.submit( );
    }

    function submitDoThat(th eform)
    {
    theform.whattod o.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@hot mail.com> wrote in message
    news:ceaf9cb9.0 402050527.5dada 43@posting.goog le.com...[color=blue]
    > 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.getAtt ributeKey().toS tring()
    > %>" value="<isa:tra nslate key="marketing. jsp.ChangeField s"/>">
    > <input type=text name="SaveMktPr ofile" value="<isa:tra nslate
    > key="b2c.market ing.profile.sav eButton"/>" class="FancyBut ton">
    > <input type=text name="CancelMkt Profile" value="<isa:tra nslate
    > key="marketing. jsp.Cancel"/>" class="FancyBut ton">
    >
    > (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="javascrip t:Submitscript( 'SaveMktProfile ')">
    >
    > <script>
    > function submitscript(ac tion){
    > document.form[1].dummy.name=act ion;
    > documen.form[1].submit();
    > }
    > </script>
    >
    > but this don't work..
    >
    > Have I just misunderstand the whole thing!?[/color]


    Comment

    Working...