Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have website with a side bar links like this

Budget
NAM
Rules
Contacts


I want the link name When user clicks the link for example he clicked (Rules) JavaScript grabs the link name for me further compare it with an if or switch statement and open the specific page the user clicked.
Posted

1 solution

Hi,

Use following

HTML
<a href="javascript:void(0)" onclick="openPage('Budget')">Budget</a>
<a href="javascript:void(0)" onclick="openPage('NAM')">NAM</a>
<a href="javascript:void(0)" onclick="openPage('Rules')">Rules</a>
<a href="javascript:void(0)" onclick="openPage('Contacts')">Contacts</a>


JavaScript
<script lang="javascript">
function openPage(page)
{
    //you can write logic here to open page.
    alert("You clicked on :" + page);
}
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900