Topic: WA.Submit('form ID') in a separate JS Function

Hi!

great Framework - but now I've been trying for 2 days and I can't find any satisfying solution for my problem.

Before calling the WA-Submit() I have to check and manipulate the Form-Data (e.g. multiplications on numeric values, if-statements on the checkboxes, ...).
My idea: call a separate JS Function with the "onload" or "onclick"- Event-Handler. In this external JS function there should be the final WA-Submit() Call.

Problem:
The form will be submitted, but I can't return to the form. Every time I get back to the Home View.

The source code of the form:

    <div class="iLayer" id="waFormERR1" title="Test">
        <a href="#" rel="action" class="iButton iBAction" onclick="checkData('form3')">OK</a>
        <a href="#" rel="back" class="iButton iBClassic" onclick="return WA.Back()">Cancel</a>
        <form id="form3" action="/WRITEPI" method="POST" onsubmit="checkData(this)">

        <div class="iPanel">
            <div id="form-res"></div>
            <fieldset>
                <legend>Setpoint Values</legend>
                <ul>
                    <input type="hidden" name="ADR1" value="MW14"/>
                    <li><label>XS</label><input id="val1" type="text" name="VALUE1" value="333" /></li>
                    <input type="hidden" name="FORMAT1" value="%d"/>
                </ul>
            </fieldset>
    </div>

and the JS function:

            function checkData(anyform) {
                alert("Do something now... but after that stay on form3 !!!");
                WA.Submit(anyform);
            }

Thank you so much.

If there are other solutions please let me know.

Re: WA.Submit('form ID') in a separate JS Function

You need to cancel the default event returning "false", so you code will be:

onsubmit="return checkData(this)"

and

function checkData(anyform) {
                alert("Do something now... but after that stay on form3 !!!");
                WA.Submit(anyform);
                return false;
}

Re: WA.Submit('form ID') in a separate JS Function

Hi Chrilith,

it works! Nice that you are back again.

Here is the complete sample code for everyone else having the same problem:

    <div class="iLayer" id="waFormERR1" title="Test">
        <a href="#" rel="action" class="iButton iBAction" onclick="return checkData('form3')">OK</a>
        <a href="#" rel="back" class="iButton iBClassic" onclick="return WA.Back()">Cancel</a>
        <form id="form3" name="myform" action="/WRITEPI" method="POST" onsubmit="return checkData(this)">

        <div class="iPanel">
            <div id="form-res"></div>
            <fieldset>
                <legend>Setpoint Values</legend>
                <ul>
                    <input type="hidden" name="ADR1" value="MW14"/>
                    <li><label>XS</label><input id="val1" type="text" name="VALUE1" value="333" /></li>
                    <input type="hidden" name="FORMAT1" value="%d"/>
                </ul>
            </fieldset>
    </div>

and

     function checkData(anyform) {
          var f = document.myform;
          var val = f.VALUE1.value * 1;
          if (val < 100 || val > 400) {
               alert("Only values between 100...400 !!!");
               f.VALUE1.value = 333;
               //do not submit and stay on form
               return false;
          }
          //do submit and stay on form
          WA.Submit(anyform);
          return false;
     }

Thank you very much again.

Re: WA.Submit('form ID') in a separate JS Function

Re: WA.Submit('form ID') in a separate JS Function