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 6980075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:58:04+00:00 2026-05-27T17:58:04+00:00

EDIT: Here’s the "better" one. First Page <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type="text/css"

  • 0

EDIT: Here’s the "better" one.

First Page

<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/redmond/jquery-ui.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
</head>
<body>
<form id="routeME" name="routeME" action="routeME.php" method="post">
<input id="key" name="key" type="hidden">
<input id="funcA" name="funcA" type="button" value="A">
<input id="funcB" name="funcB" type="button" value="B">
<input id="funcC" name="funcC" type="button" value="C">
</form>

<script type="text/javascript">

$('form#routeME :button').click(function() {
   $('#key').val($(this).attr('id'));
   $('form#routeME').submit();
});

</script>
</body>
</html>

Landing Page

<?php

$value = $_POST['key'];

if (isset($value)) call_user_func($value);

function funcA(){
    echo 'function A NEW!';
    }
function funcB(){
    echo 'function B NEW!';
    }
function funcC(){
    echo 'function C NEW!';
    }
?>

Below is the first posting…

If you have an HTML form and you POST it to a .php page, how can you pick up what the link or class was that was clicked on? I’m trying to run a .php function on the landing page depending on what link was clicked on in a JQuery function on the POSTing page. Here’s what I’m doing right now.

First Page

<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/redmond/jquery-ui.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script type="text/javascript">

$(document).ready(function(){
    $("#funcA").click(function(){
        $('form#routeME').attr({action: "routeME.php"});
        $('#key').val('A');
        $('form#routeME').submit();
    });
    $("#funcB").click(function(){
        $('form#routeME').attr({action: "routeME.php"});
        $('#key').val('B');
        $('form#routeME').submit();

    });
    $("#funcC").click(function(){
        $('form#routeME').attr({action: "routeME.php"});
        $('#key').val('C');
        $('form#routeME').submit();
    });
});
</script>
</head>

<body>

<form id="routeME" name="routeME" action="routeME.php" method="post">

<input id="key" name="key" type="hidden">

<input id="funcA" name="funcA" type="button" value="A">
<input id="funcB" name="funcB" type="button" value="B">
<input id="funcC" name="funcC" type="button" value="C">

</form>
</body>
</html>

PHP Landing page

<?php

$value = $_POST['key'];
//echo $value;

if (($value=='A')) {
    A();
    } else if (($value=='B')) {
        B();
        }else if (($value=='C')) {
            C();
            }

function A(){
    echo 'function A!';
    }
function B(){
    echo 'function B!';
    }
function C(){
    echo 'function C!';
    }

?>

It’s doing what I want in a round about way but is there a better way to get what I want??

Thanks!

  • 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-27T17:58:04+00:00Added an answer on May 27, 2026 at 5:58 pm

    I believe you’re looking for the call_user_func function

    if (isset($value)) call_user_func($value);
    

    call_user_func Calls the function with the name passed by $value, so if you submitted ‘A’, your script would run the A() function.

    EDIT: If you happen to know what “range” of functions to call, you could do a check I’ve commonly used.

    if (isset($value))
    {
        $array = array('function_1', 'function_2', 'function_3');
        if (in_array($value, $array))
        {
            /* The $value is expected, so try to run the function */
            call_user_func($value);
        }
        else die("Invalid function passed!");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

edit: I was trying to solve a spoj problem. Here is the link to
[EDIT: Here's a link to a mockup of what I'm trying to create] http://i53.tinypic.com/w9v2np.jpg
EDIT: Here's a link to show you my sample code: http://www.singingeels.com/jqtest/ I have a
Edit - here are some resources in response to comments: costate: http://bamafolks.com/randy/students/embedded/dynamicC_mtask.html writeUserBlockArray: http://ftp1.digi.com/support/documentation/html/DynCFunctionReference/12fun595.htm#1259708
Edit: The code here still has some bugs in it, and it could do
EDIT - The code looks strange here, so I suggest viewing the files directly
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
Edit: OK I asked the wrong question here. I'm going to be coding a
EDIT Sorry I forgot the most important part here. Each key can have more

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.