How to simulate clicking the php button in php
Session_start ();
Require ("config. php ");
$ Db = mysql_connect ($ dbhost, $ dbuser, $ dbpassword );
Mysql_select_db ($ dbdatabase, $ db );
If ($ _ POST ['submit ']! = ""){
$ Username = $ _ SESSION [username];
$ City = $ _ POST [city];
$ Attraction = $ _ POST [attraction];
$ ImageNum = $ _ POST [number];
$ Relevance = $ _ POST [relevance];
$ SQL = "Insert Into vote (username, city, attraction, imageNum, relevance, dateposted) Values ('$ username',' $ City', '$ traction ', '$ imagenum',' $ relevance ', NOW ())";
$ Result = mysql_query ($ SQL );
Echo "script" alert ('rating successful! ') Script ";
Echo "script" document. getElementById ('addbutton '). click (); script ";
}
?>
The code above indicates that I am evaluating images. the Function I want to implement is to automatically jump to the next image after each successful evaluation (addButton's function is to jump to the next image ), simulate clicking "addButton", so you don't need to manually click the button. please help me...
Reply to discussion (solution)
Your addButton click event triggers a method.
Why not write this method behind alert?
Automatically jump to the next one. what does the page mean to output the next one?
If your button is under the php code, it will become invalid. Therefore, a window. onload = function (){............}
Your addButton click event triggers a method.
Why not write this method behind alert?
I don't know why. js custom functions cannot be executed in php...
Automatically jump to the next one. what does the page mean to output the next one?
Yes, it was originally evaluated. manually click addButton to jump to the next one. what I want to achieve now is that after the evaluation is complete, it will automatically jump to the next one, so you don't need to click it manually.
If your button is under the php code, it will become invalid. Therefore, a window. onload = function (){............}
Which outer layer? Just a short start .. Not very familiar. can you be specific,
Echo "script window. onload = function () {document. getElementById ('addbutton'). click ();} script";
Echo "script window. onload = function () {document. getElementById ('addbutton'). click ();} script";
I have solved it myself, but I still need to thank you ~~
I still don't know how to execute js code in php. for example, I defined
Function login (){
Alert ("please log on! ");
}
How can I execute such a function in php?
How does LZ solve this problem? Share
1. a prompt box is displayed, and the page is automatically redirected to the specified page:
Function alertInfor ($ infor = false, $ href = false) {echo <