Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all, you can't execute JavaScript from within PHP like this. At this point, the control has already moved to the server and JavaScript is run on the client-side. </p> <p>Second of all Im assuming you dont want to just follow the link, you want to run the link's onClick event, since the href is just a hashtag. So you are trying to run a JavaScript function with PHP. You cant call a function in one language from a function in another language.</p> <p>Its hard to tell what exactly you are trying to do, but if you want to run a function when a user selects a certain dropdown, write a php function that does what archiveMove() does. If you want this to happen without a page refresh, you can stop the submit process and call your archiveMove() function with javaScript and Ajax. </p> <p>If elaborate on what exactly you are trying to do, maybe we can help more. </p> <hr> <p>Ok, so the only difference between your working code and the not working code is that you want to dictate the submitted URL based on what is selected in the dropdown? </p> <p>So you can use JavaScript to set the form action when the dropdown is selected.</p> <p>BUT, It might be a better idea to submit the form with the same action everytime, and then use PHP to decide what to do. It seems like this is where you were headed initially. Just get the folder id in the switch statement and call a function to make your edits:</p> <p>The PHP can be similar to the way you had it: </p> <pre><code> switch ($_POST['dropdown']) { case "Two": // set folder id $folder_id = 2; break; } moveMessages($_POST['Messages'], $folder_id); </code></pre> <p>function that moves the messages where they need to go. </p> <pre><code> function moveMessages($messages, $folder_id){ // depending on your form setup foreach($data as $id =&gt; $value ){ if($value){ // code to move to folder } } return true; } </code></pre> <p>If there are other factors involved, let me know.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload