0

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>
?>
2
Contributors
6
Replies
18
Views
4 Years
Discussion Span
Last Post by shrikanthnk
0

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.

0

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

0

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>
?>
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.