3

i have this input field:

<input type="submit"  name="rregjistro" value="Rregjistro Tani Te Dhenat" onclick="openmodal()" >

I want first to execute POST script in PHP and than to open a modal popup using a javascript function.

Can you please help me! Thanks in advance!

2
  • 5
    consider using ajax Commented Sep 9, 2016 at 15:06
  • 5
    Run Ajax query. Then in callback - open popup. Commented Sep 9, 2016 at 15:09

2 Answers 2

4

It is not possible to click using PHP because form submission is the action on the client's side, i.e in your browser. Events in the browser like this can be executed by javascript or other client language.

<form ... >
<input type="submit"  name="rregjistro" value="Rregjistro" />
<!-- remove onclick attribute for now -->

</form>

<div id="myResult"></div>

<script>
$(function(){
    $("input[name=rregjistro]").click(function(){
        // url needs to belong to your domain
        $.ajax({url: "/your_url_path", success: function(result){
            $("#myResult").html(result);
            open();
        }});
    });
});
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

You would still need to start with a javascript function first.

In jquery that would be something like that:

function open() {
  $.post('http://url', $('#form').serialize(), function() {
    alert('popup goes here');
  })
)

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.