0
votes

I'm putting a camera button in a form so you can take the photo and it'll save the URI to a localStorage variable. The problem is every time the camera launches, the form is submitted without me hitting the submit button so the URI is never stored. I need it not to trigger submitForm(). Any insights?

Oh, the app is using jquerymobile.

html form

            <form method="post" onsubmit="return submitForm()" id="myForm" data-ajax="false">
                <lable for="title" class="ui-hidden-accessible">Title</lable><input type="text" name="title" placeholder="Title"><br>
                <button onclick="capturePhoto()">Camera</button><br>
                <input type="text" name="description" placeholder="description">
                <input type="submit" value="submit">
            </form>

js

function submitForm() { db.transaction(insertDB, errorCB); $.mobile.changePage( "#page2", { reverse: false, transition: "slide" } ); return false; }

function capturePhoto() { // Take picture using device camera and retrieve image as base64-encoded string navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI }); }

1

1 Answers

0
votes

Found the problem. I used the <button> tag for the Camera. This will trigger an onsubmit event. I used a regular <a href> in stead and that worked.