JChilds Posted June 12, 2008 Share Posted June 12, 2008 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 /> Quote Link to comment Share on other sites More sharing options...
haku Posted June 12, 2008 Share Posted June 12, 2008 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. Quote Link to comment Share on other sites More sharing options...
JChilds Posted June 12, 2008 Author Share Posted June 12, 2008 Ok, Well here is what I have got so far: var page = window.document.body.createTextRange(); var secretary = page.match (/Secretary <b>\(Floor \d{1,2}/i); onClick="MsgBox(secretary)"; Quote Link to comment Share on other sites More sharing options...
haku Posted June 12, 2008 Share Posted June 12, 2008 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! Quote Link to comment Share on other sites More sharing options...
JChilds Posted June 12, 2008 Author Share Posted June 12, 2008 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. Quote Link to comment Share on other sites More sharing options...
haku Posted June 12, 2008 Share Posted June 12, 2008 Do you want the button to only reference the secretary, or do you want it to be able to reference all offices. And if it's all offices, how will the button know which one you are referring to? Quote Link to comment Share on other sites More sharing options...
JChilds Posted June 12, 2008 Author Share Posted June 12, 2008 Just secretary. There will be a few buttons. Each one 'referencing' a different office. Quote Link to comment Share on other sites More sharing options...
haku Posted June 12, 2008 Share Posted June 12, 2008 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() } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.