Data Does Not Pass Before Submit

Asked

Viewed 29 times

0

good afternoon. I’m new to the forum and new to programming and I’m stuck in an action.

I am calling a modal window for the user to enter some information and when clicking save the information goes to inputs within the form and the form is submitted.

The problem is that when Pure Code everything happens at the time it should, but when the code runs normal the information does not enter the inputs and the query breaks. As if Submit was first that update.

I’d like to understand what I’m doing wrong and why it happens.

Code:

1º I create together with the page the empty input:

<input type='text' value='' id='vN'>

2º In the event button click in the modal window Jquery below moves the field information of the modal window to the input in the form and calls the Submit:

$("#vN").val($("#numNegocio").val());
$("#btSalvar").click(); 

3º The input value would be used in the PHP save function, but when it arrives at this point the information is no longer in the input:

$n01 = isset($_POST['vv'])?$_POST['vN']:"";
  • Hello Carlos, it would be better to post more code that you are using. Only these that you entered open up a range of possibilities that may be errors.

  • 1

    If your modal is inside the form in the code, all inputs belong to the form and you do not need to do this value transposition.

  • 1

    One of the problems is related to the <input type='text' value='' id='vN'> who doesn’t have a name, so php won’t identify it. The right one would be <input type='text' value='' id='vN name='vN'>

  • @Andersoncarloswoss Unfortunately it is not inside the same form, by a limitation of mine that I could not format the modal correctly when I put it inside the form. Sorry my nubisse ... I’m starting with web now.

  • 1

    @Andreicoelho Andrei, ball show!!! That’s right. Thank you so much! It only includes the name and worked exactly as it should. Thanks anyway!

  • @Carloshenriquejr cool! Glad it worked!

Show 1 more comment

1 answer

1


As commented by Andrei Coelho, the problem was in the absence of the name in the element. Thereby the $_POST['vv'] was not receiving the value of the field. Just add the name:

                                     ↓↓↓
<input type='text' value='' id='vN' name='vN'>

Browser other questions tagged

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