Jump to content

javascript help


JChilds

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
Share on other sites

This forum is for helping people with code they are having troubles with. If you need code written for you, you can head to the freelance section of the forum and post something up there, and I'm sure you will get  many many responses by people willing to help you out.

 

Link to comment
Share on other sites

So to confirm, you want to be able to click on 'Secretary Office (Floor 6)', and have a little alert message pop up with the number '6' in it?

 

And if so, pardon my asking, but what is the point of that, since they can already see in the link that it is floor 6!

Link to comment
Share on other sites

There is about 700 offices.

 

I want to put a button at the top of the page, and when i click that button, It will tell me which level (in this case) the secretary office is on, without me having to scroll through the list to find it.

 

Link to comment
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
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.