submitting a form on android using java script

By : Zatla00
Source: Stackoverflow.com
Question!

I use the following javascript code to validate/submit my form:

function SendForm()  {
            var formlist = document.getElementById ("formlist");
            var buttonRadios = document.getElementsByName ("film");
            var selected = false;
            for (var i = 0; i < formationRadios.length; i++) {
                if (formationRadios[i].checked) {
                    selected = true;
                    break;
                }
            }
            if (selected) {
                 document.formlist.submit ();

            }
            else {
           //nothing to do
            }            
        }

In the Html side:

<form  method="post" name="formlist"  action="films.php" OnChange="SendForm();">
...
<input type="radio" name="film" id="spman" value="spman" required="required"><label for="spman">Spider Man</label>
...

<select class="required" name="date" id="date">
<option selected value="13-05-2012">13 May 2012</option>
...
</select>
</form>

This works with firefox beta under android but not with the android default browser. It also works with firefox desktop browser.

Could you tell me what's wrong with it, I don't have errors inf firebug console.

Update:

I finally found the problem, it doesn't come from the code but from the iPhone/iPad bug with checking radio box when clicking label, for further information:

http://v4.thewatchmakerproject.com/blog/how-to-fix-the-broken-ipad-form-label-click-issue/

Thank you all for your help.

By : Zatla00


Answers
Since Android 2.2 the built-in browser doesn't support the access of forms through the document object (Like document.name_of_your_form.submit()). Try one of the following possibilities:

id attribute:

HTML

<form id="formlist">

JavaScript

var formlist = document.getElementById("formlist");

name attribute

HTML

<form name="formlist">

JavaScript

var formlist = document.forms["formlist"];

or

var formlist = document.formlist;


This video can help you solving your question :)
By: admin