Form opening blank JS popup

Asked

Viewed 76 times

0

I need to return the result of a form submission in a popup (I tried lightbox but I penetrated to be able to use, would be better, recommendations?) in the center of the user screen, the only problem is that the popup is returning a blank page and I could not identify where is the error in the code.

If I put 'include/verifies.php' in window.open it gives several error messages, it does not resolve.

Form:

<form action="include/verifica.php" onsubmit="return abrirPopup('this', 400, 120)" method="POST">

JS:

function abrirPopup(form, w, h) {
  var newW = w + 100;
  var newH = h + 100;
  var left = (screen.width - newW) / 2;
  var top = (screen.height - newH) / 2;
  var newwindow = window.open('', 'formpopup', 'width=' + newW + ',height=' + newH + ',left=' + left + ',top=' + top);
  form.target = 'formpopup';
  newwindow.resizeTo(newW, newH);

  //posiciona o popup no centro da tela
  newwindow.moveTo(left, top);
  newwindow.focus();
  return false;
}

The form is in my index, it checks if all the data has been entered in the check.php in positive case it includes the insert.php which is who plays the data to the database and returns me a protocol number, which is the id of the new line in the table.

Sorry for the mess of the code but this is mostly for the amount of times I’ve changed it in desperation to try to fix haha

1 answer

2

is missing put the address of the popup in

var newwindow = window.open('ENDEREÇODAPOP', 'formpopup', 'width=' + newW + ',height=' + newH + ',left=' + left + ',top=' + top);
  • If so, if I put the address, it checks.php or inserts.php it returns errors like this: Notice: Undefined index: data_coleta in C: Arquivos de programas Apache Software Foundation Apache2.2 htdocs sistemas projeto include verifies.php on line 13

  • but this error is from the page verifies.php, you have already opened this page directly in the browser?

  • and what’s on that line 13?

  • This is weird, either open the pop and the form action does not work, or the action works and does not open the pop

  • Your question would not be: When you submit the form to include/verifies.php, return the result of submitting this form in a popup in this include/verifies.php?

  • When the form says open in a new tab the registration completes perfectly. The two errors I have: 1- If there is no target in the window.open the popup opens blank. 2- If target to popup is one of the two pages of the registration process (verifies.php and inserts.php) the popup opens with error (I imagine it does not properly process their contents).

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.