Jump to content

Recommended Posts

Firstly, I have absolutely no insight into javascript, at all.

So please bear with my ignorance  ???

 

I have a webpage with a list of locations, and what floor they are on in a building.

 

I need to write some javascript that will (when a button is pressed) , tell me which floor the Secretary office is on, and display it in a prompt. eg:  6

 

 

Here is an example of the text on the page:

....

Secretary Office (Floor 6)

Employee Gym (Floor 2)

....

 

How would I go about doing this?

 

Many thanks in advance!

 

edit: If it matters, here is the source of that particular part of the page:

Secretary Office <b>(Floor 6)</b><br />
Employee Gym <b>(Floor 2)</b><br />

Link to comment
https://forums.phpfreaks.com/topic/109816-javascript-help/
Share on other sites

HTML:

<a href="#" id="secretary_link">Secretary</a>

 

Javascript (put this in script tags in the head of your document)

function secretaryListener()
{
   var targetA = document.getElementById("secretary_link")
   targetA.onclick = function()
   {
      alert("6");
   }
}

window.onload = function()
{
   secretaryListener()
}

Link to comment
https://forums.phpfreaks.com/topic/109816-javascript-help/#findComment-564031
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.