Tuesday 18 March 2014

Pass Values Using Anchor Tag

Methode: 1


<a href="urlink.php?myvalueone=1&myvaluetwo=2">Pass Values</a>


In urlink.php

<?php   

    echo $_REQUEST["myvalueone"];
    // OR
    echo $_GET["myvalueone"];

    //AND

    echo $_REQUEST["myvaluetwo"];
    //OR
    echo $_GET["myvaluetwo"];

    //Process your actions here
   
?>

Result: 1122



Methode: 2

 

<form action="urlink.php" method="POST">

<input type="hidden" name="myvalueone" value="1" />
<input type="hidden" name="myvaluetwo" value="2" />

<a href="#" onclick="this.parentNode.submit()">Pass Values</a>

</form>


In urlink.php

<?php
       
    echo $_REQUEST["myvalueone"];
    // OR
    echo $_POST["myvalueone"];

    //AND

    echo $_REQUEST["myvaluetwo"];
    //OR
    echo $_POST["myvaluetwo"];
   
    //Process your actions here

?>

Result: 1122



Methode: 3


<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>

<a href="#NOD" rel="2" id="myvalues">Pass Value</a>

<script type="text/javascript">

    $(document).ready(function() {
        $('#myvalues').click(function() {
            $.ajax({
                type: "POST",
                url: "urlink.php",
                data:  {'myvalue' : $(this).attr('rel')},
                success: function(data) {
                alert(data);
                }
            });
    });
    });

</script>


In urlink.php

 
<?php
    //Process your actions here
    echo $_POST['myvalue'];
?>

Result:Javascript alert, popup with value 2

1 comment:

  1. According to Stanford Medical, It's in fact the ONLY reason women in this country live 10 years more and weigh 19 KG less than we do.

    (And really, it is not about genetics or some secret-exercise and absolutely EVERYTHING about "HOW" they are eating.)

    P.S, What I said is "HOW", and not "WHAT"...

    TAP on this link to reveal if this easy test can help you find out your real weight loss possibility

    ReplyDelete