Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7063531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:43:28+00:00 2026-05-28T04:43:28+00:00

To put it simply I have this variable which carries a hyperlink: $test3 =

  • 0

To put it simply I have this variable which carries a hyperlink:

$test3 = '<a href="#" onclick="archiveMove(\''.$mulmov.'\'); return false;">Move to Quotes</a>';

and what I need is to execute this variable inside a switch case like below:

switch ($_POST['dropdown'])  { 

    case "Select Folder":
    echo "Please select";
    break;

    case "One":
    exec($test3); <-- //here i want to run (if this is not execute, my misunderstanding) the link.


    break;

    case "Two":
    header('Location: http://www.facebook.com/'); <-- //this is just a test

    break;


default:
  echo "<br></br>";
  echo "Move multiple files:";
  echo "<br></br>";

  }


  ?>

  <form method="post" name="theform" action="">
    <select name="dropdown">
    <option value="Move to Folder">Select</option>
    <option value="One">One</option>
    <option value="Two">Two</option>
    </select>
    <input type="submit" value="Move"/>
</form>

I’d like know how to execute the ahref link without the user clicking it, but simply set this link as a case and when the user submits the form, the selected case actions the hyperlink.

Any help appreciated.


MORE DETAIL

I understand that javascript and php are both seperate languages and that a better option would be to use Ajax, but my understanding of Ajax is limited.

To explain it better, this is what’s going on in its entirety:

1) I have a mailbox with a selection of messages.

2) You are able to check these messages and then click a link “Trash Selected” which deletes the selected messages. This the link:

<a href="#" onclick="deleteInbox(\''.$muldel.'\'); return false;">Trash Selected</a>

The javascript function actions the php function in $muldel for all selected messages and updates the database.

This is the javascript function in question:

function inboxDelete(url) {
    document.messages.action = url;
    document.messages.submit();
}

archiveMove() is exactly the same, just duplicated temporarily to make things clear.

3) I have now re-used the ahref code to do the same procedure, but this time, for moving the selected messages into folders.

4) These folders can be selected from a drop down box – this is where the form comes in.

5) So although I can get it to work by adding a link like such:

 $test3 = '<a href="#" onclick="archiveMove(\''.$mulmov.'\'); return false;">Move to Quotes</a>';

echo $test3;

6) I now need this to work the same way but the link being changed, depending on which folder is selected.

That’s the full extent to my problem, I hope this is more clear.

I am aware you can send variables into javscript using GET or POST and then carry out the function entirely through javascript. I have tried something like below, but to no avail:

<form method=post name="myform" action="<?php echo $PHP_SELF;?>">
    <input type="hidden" name="formVar" value="">
    <input type="text" value="Enter Text Here" name="myText">
    <input type="text" value="Enter Text Here" name="myText2">
    <input type="submit" value="Send form!" onClick="readmove()">
</form>



 <?php
    // Retrieve the hidden form variable (using PHP).

    $myvar = $_POST['formVar'];

    if ($myvar == "$mulmov"){
        echo $mulmov; 
    }

    ?>
        <script language="JavaScript">
    <!--
    function setText(){
      document.myform.myText.value = document.myform.myText.value.toUpperCase();
    }


     function readmove(){
        document.myform.myText.value = "<?php echo $myvar; ?>" ; 
        readmove2();

    }


    function readmove2(){
        if (document.myform.myText.value == "$mulmov"){
            document.myform.myText2.value = "<?php echo $mulmov; ?>" ; 
            <?php exec ('archiveMove(\''.$mulmov.'\');  return false;'); ?>
    } else if (document.myform.myText.value == "$mulmov2"){
            document.myform.myText2.value = "<?php echo $mulmov2; ?>" ; 
    }
    }

</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:43:29+00:00Added an answer on May 28, 2026 at 4:43 am

    Ok this was my solution but thank you also for your solution Jeff Ryan, this worked also.

    <script language="javascript">
    
    
    
     function buttons(str) 
    {
    document.getElementById("txtHint").innerHTML = str; 
    
    if (document.f1.users.options[1].selected){
        document.getElementById("txtHint").innerHTML ="<?php echo $mulmov; ?>";
        document.messages.action = document.getElementById("txtHint").innerHTML;
    
    
    }
    else if (document.f1.users.options[2].selected){
        document.getElementById("txtHint").innerHTML ="<?php echo $mulmov2; ?>";
        document.messages.action = document.getElementById("txtHint").innerHTML;
    
    
    }
    }
    
    function submit_mes(str)
    {
    
        document.messages.submit();
    }
    
        </script>
    
        <form name="f1">
    <select name="users" onChange="buttons(this.value)">
    <option value="">Select a folder:</option>
    <option value="Quotes">Quotes</option>
    <option value="Projects">Projects</option>
    
    <input type="button" value="Move" onClick="submit_mes(this.value)">
    </select>
    </form>
    
    <div id="txtHint"><b>Folder will be listed here.</b></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a new project which simply put, is an attempt to formalize the
Very simply put: I have a class that consists mostly of static public members,
Very simply put, I have the following code snippet: FILE* test = fopen(C:\\core.u, w);
Simply put, I have a table with, among other things, a column for timestamps.
Simply put I want what http://www.reddit.com/ and http://news.ycombinator.com/ have to the left of every
This is a bit maddening. I have code which saves the current background-image from
Put simply: it causes a massive memory leak within an hour if I work
Simply put, is there a way to create a 2D javascript array using similar
Simply put, MVC is the pattern for separating contents (model) from presentation (view), and
Simply put; what does my $99 get me, that I can't already get for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.