1

I have a new website. In this website, the user enters values in the Name & Email in text fields and then the user clicks an anchor to get a unique link.

Now the thing is, I want to save data from input type text (Name & Email). I know how to do it if there is a submit button, but how can I save data without a submit button?

I want to save data in a database via PHP.

3
  • show what have you tried? Commented Jun 28, 2016 at 6:50
  • Can you show your attempt(s) please? Also if you don't want a submit button, how do you plan to detect the client has finished inputting data into the Name & Email fields? Commented Jun 28, 2016 at 6:51
  • 1
    you got to have an event that will fire so you can save your data.. if you dont want a button then you can have keyup on input but that is just to difficult since you have multiple input... but i think having a button is the best option Commented Jun 28, 2016 at 6:52

2 Answers 2

2

You can use Javascript to submit your form without using a submit button. Use the code written below and modify it accordingly:

<form name="myform">
     <input type="text" />
     <button class="buttonFinish"></button>
 </form>

 <script type="javascipt">
    $(document).ready(function() {
        $('.buttonFinish').click(function(){
            $('.myform').submit();
        });
    }
  </script>
Sign up to request clarification or add additional context in comments.

1 Comment

It works!!! I think this is one of the ways where you can submit without using submit button.
0

Made an AJAX call on key enter by checking if(keycode == '13') and call your server side method by validating it.

1 Comment

This should be posted as a comment as this doesn't really offer any solution/answer, this is more of a Suggestion with no example/source code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.