Hi ,

Kindly help me to display tempnum when ahref is clicked. Looks like code marked as Italic requires needs to be updated??

<html>
<head>
    <script type="text/javascript" src="jquery-2.0.3.min.js"></script>
    <script type="text/javascript">
                    $(document).ready(function(){
                    $(".mylinktempnum").click(function(){
                     *alert($(this).attr('this.tempnum'));*
                    });
                    });
    </script >

</head>
<body>
</body>
</html>


<?php
<a class=\"mylinktempnum\" href=\"home.php?tempnum=$num\"></a>
?>

Recommended Answers

All 6 Replies

you would have to use a regex expression to extract that from the url which is somewhat pointless in this case. Not sure what you're trying to accomplish but it may be easier to use the html onclick attribute to call a function with the parameter passed to it:

<script>
    function link_click(tempnum)
    {
        alert(tempnum);
    }
</script>

<a href="javascript:" onclick="link_click('<?= $num; ?>');">Click Me</a>

But again I don't know what you're trying to accomplish so this may not be the best route for you.

Sorry, I need to use Jquery to get tempnum as I'm passing this value to the server to retrieve few more things... Please help. Thank you

I would never use this for a few different reasons, but it will accomplish what you're asking

<html>
<head>
    <script type="text/javascript" src="jquery-2.0.3.min.js"></script>
    <script type="text/javascript">
                    $(document).ready(function(){
                    $(".mylinktempnum").click(function(){
                        alert($(this).attr('href').match(/tempnum=([0-9]+)/)[1]);
                    });
                    });
    </script >

</head>
<body>
</body>
</html>


<?php
<a class=\"mylinktempnum\" href=\"home.php?tempnum=$num\"></a>
?>

Thanks a lot...It worked ...I can proceed further to get other values....

Appreciated your help on this...

Between could you please provide me the link here to understand regex method.

Cool..

Thanks Again !!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.