Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by paul on Jul 30, 2008 02:06
open dhtmlx forum
form submits no data by calling .submit() from code

Hello!

I want to validate the data to meet some criteria before submitting the form integrated grid content.
The validate/submission process is initiated by
<button onclick="doSubmit()">Submit changes</button>
and is done in some way inside the doSubmit() function, which ends with following expressions:
    if (!isFormDataValid) {
        return false;
    }
    document.forms[0].submit();

I'm now faced to following problem:

1) if the above mentiomed button is located inside the same form with datagrid, the form will be submited anyway - regardless of return from doSubmit() function

2) if the button is placed outside the form, the submission is done just at the moment declared by doSubmit() function BUT the form sumbits absolutely NO DATA from grid

This makes me think that the form inegration hangs itself somehow onSubmit event of the form to perform some initialization operations. However it provides no functionality to interrup the submission process (if needed). On the other side it doesn't perform the needed operations if the submit() method of the form is called outside the form.

MY QUESTION now is:
How can I validate the grid data immediately before submitting and proceed the user to make some changes (if needed) or to submit the grid data?

Thanks
Answer posted by Support on Jul 30, 2008 05:13
>>BUT the form sumbits absolutely NO DATA from grid
The grid set handler on submit event of form, but this event doesn't generated when you calling submit() as a method of form.
You can force grid data sending by using   

    grid.formCreateInputCollection();   // this command will force grid data sending
    form.submit();
Answer posted on Jul 30, 2008 06:49
Thank you for answering!

BUT could you please ALSO say, if there is a way to perform check and to CANCEL form submitting having the button INSIDE of the form.

This become essentionally because of layout issues.
Answer posted by Support on Jul 30, 2008 10:07
The case with button inside form not related to grid's functionalit. I think the next will resolve issue.

<button onclick=" (arguments[0]||event).cancelBubble=true; return doSubmit()">