0

Hi,

My Name is Ravi Shankar. I have query in PHP Code. I had written the code as if client click on check box, it will generate 16 digits random number in adjacent text box.

My query is, before display the 16 digits random number i have to show a pop-up message and click YES we have to insert the data into mysql database. if NO don't display the random number. Is it possible to insert the data into mysql when i click the pop-up message. I tried to get the values but from JavaScript $_POST values id not getting.

Can anybody give the solution for this.. I am new to this PHP coding.

Thank a lot

Regards,

Ravi

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by diafol
0

Hi,

My Name is Ravi Shankar. I have query in PHP Code. I had written the code as if client click on check box, it will generate 16 digits random number in adjacent text box.

My query is, before display the 16 digits random number i have to show a pop-up message and click YES we have to insert the data into mysql database. if NO don't display the random number. Is it possible to insert the data into mysql when i click the pop-up message. I tried to get the values but from JavaScript $_POST values id not getting.

Can anybody give the solution for this.. I am new to this PHP coding.

Thank a lot

Regards,

Ravi

try submitting the form After clicking on the YES. Or otherwise make an Ajax call to insert the data into MySQL.

0

use confirm()in java script. if you click ,submit the form and write insert query to insert the data into db , if you click cancel it will not do any thing

0

use confirm()in java script. if you click ,submit the form and write insert query to insert the data into db , if you click cancel it will not do any thing

Thank you for all your reply....!

But here i am not using any submit button. I want the $_post values after i click 'YES' from java script.
Here one thing i want to say.. i am using 10 check box's and text box's to generate each check box a random number. So if u check 1st check box i have to get pop-up message saying yes/no, if i click yes then text box random generated value has to show otherwise not.

could anybody tell me some sample code for this query using AJAX or JAVA SCRIPT.

Regards,

Ravi

0

Use JS random number generator - no need for php until you submit the form (if at all).

var rnd=Math.floor(Math.random()*11);

This will give a random number between 0 and 10. For any other ranges - change the integer (11).

Use this in conjunction with a confirm popup. Use the result (yes/no) to populate the appropriate textbox (or not).

function do_confirm(id)
{
var c=confirm("Show a random number?");
if (c==true)
  {
  document.getElementById(id).value = Math.floor(Math.random()*11);
  }
}

This code is run from your checkbox -

onclick="do_confirm('textbox2');"

- you may have to check the state of the checkbox, otherwise you may get a popup whenever you click the box (off and on). JS not my thing, so not sure if this will work out of the box.

Edited by diafol: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.