JavaScript - Expandable Table Of Contents... School Final Project
Hey thanks in advance to anyone who can take a peak at my code and hopefully point me in the correct direction.
I have been working on my final project in my javascript class for a bit, and there are a few erros I cant seem to find through firebug or error console. It is due this evening at midnight, so anyone that could help, I really need this assignment for a decent grade. Basically there are two issues so far, one needs to be solved so the other can be as well. First, line 103 - 105 should create a hyperlink to the specified id, but is doesn't return a number. so the link goes no where it is this code: PHP Code: //create hypertext link to the section heading var linkItem = document.createElement("a"); linkItem.innerHTML = n.innerHTML; linkItem.href = "#" + n.id; Next I belive there is a problem with the function expandCollapseDoc(), that might fix itself when the other problem is solved. The document should expand and collapse with the menu. Here is my javascript code: PHP Code: /* New Perspectives on JavaScript, 2nd Edition Tutorial 7 Tutorial Case Author: Mike Cleghorn Date: 2-15-10 Filename: toc.js Global Variables: sections An array contain the HTML elements used as section headings in the historic document Functions List: addEvent(object, evName, fnName, cap) Adds an event hander to object where evName is the name of the event, fnName is the function assigned to the event, and cap indicates whether event handler occurs during the capture phase (true) or bubbling phase (false) makeTOC() Generate a table of contents as a nested list for the contents of the "doc" element within the current Web page. Store the nested list in the "toc" element. levelNum(node) Returns the level number of the object node. If the object node does not represent a section heading, the function returns the value -1. createList() Goes through the child nodes of the "doc" element searching for section headings. When it finds a section heading, a new entry is added to the table of contents expandCollapse() Expands and collapse the content of the table of contents and the historic document expandCollapseDoc() Goes through the child nodes of the "doc" element determining which elements to hide and which elements to display isHidden(object) Returns a Boolean value indicating whether object is hidden (true) or not hidden (false) on the Web page by examining the display style for object and all its parent nodes up to the body element */ function addEvent(object, evName, fnName, cap) { if (object.attachEvent) object.attachEvent("on" + evName, fnName); else if (object.addEventListener) object.addEventListener(evName, fnName, cap); } addEvent(window, "load", makeTOC, false); var sections = new Array("h1","h2","h3","h4","h5","h6"); var sourceDoc; //document on which TOC is based on function makeTOC(){ var TOC = document.getElementById("toc"); TOC.innerHTML = "<h1>Table of Contents</h1>"; var TOCList = document.createElement("ol"); TOC.appendChild(TOCList); sourceDoc = document.getElementById("doc"); //generate list items containing section headings createList(sourceDoc, TOCList); } function levelNum(node) { for (var i = 0; i < sections.length; i++) { if(node.nodeName == sections[i].toUpperCase()) return i; } return -1; //node is not section heading } function createList(object, list) { var prevLevel = 0; //level of the pervious TOC entry var headNum = 0; //running count of headings for (var n = object.firstChild; n != null; n = n.nextSibling) { //loop through all nodes in object var nodeLevel = levelNum(n); if (nodeLevel != -1) { //node represents a section heading //insert id for the section heading if necessary headNum++; //create list item to match var listItem = document.createElement("li"); listItem.id = "TOC" + n.id; //create hypertext link to the section heading var linkItem = document.createElement("a"); linkItem.innerHTML = n.innerHTML; linkItem.href = "#" + n.id; //append the hypertext to the list entry listItem.appendChild(linkItem); if (nodeLevel == prevLevel) { //append the entry to the current list list.appendChild(listItem); } else if (nodeLevel > prevLevel) { //append entry to new nest list var nestedList = document.createElement("ol"); nestedList.appendChild(listItem); list.lastChild.appendChild(nestedList); //add plus/minus box beffore the text var plusMinusBox = document.createElement("span"); plusMinusBox.innerHTML = "--"; addEvent(plusMinusBox, "click", expandCollapse, false) nestedList.parentNode.insertBefore(plusMinusBox, nestedList.previousSibling); list = nestedList; prevLevel = nodeLevel; } else if (nodeLevel < prevLevel) { //append entry to a higher-level list var levelUp = prevLevel - nodeLevel; for (var i = 1; i<= levelUp; i++) {list = list.parentNode.parentNode;} list.appendChild(listItem); prevLevel = nodeLevel; } } } } function expandCollapse(e) { var plusMinusBox = e.target || event.srcElement; var nestedList = plusMinusBox.nextSibling.nextSibling; //Toggle the plus and minus symbol if (plusMinusBox.innerHTML == "--") plusMinusBox.innerHTML = "+" else plusMinusBox.innerHTML = "--"; //Toggle display of nested list if(nestedList.style.display == "none") nestedList.style.display = "" else nestedList.style.display = "none"; //expand/collapse doc to match TOC expandCollapseDoc(); } function expandCollapseDoc() { var displayStatus = ""; for (var n = sourceDoc.firstChild; n != null; n = n.nextSibling) { var nodeLevel = levelNum(n); if (nodeLevel != -1) { //determain display status of TOC entry var TOCentry = document.getElementById("TOC" + n.id); if (isHidden(TOCentry)) displayStatus = "none" else displayStatus = ""; } if (n.nodeType == 1) { //apply to current status for the node n.style.display = displayStatus; } } } function isHidden(object) { for (var n = object; n.nodeName != "BODY"; n = n.parentNode) { if (n.style.display = "none") return true; } return false; } the html was too long, so i uploaded it to my webspace you can check out the almost working version at http://www.kinetic-designs.net/final/usconst.htm Again thank you so much! Any questions just ask! Similar TutorialsI am trying to create a grading calculator which will prompt the user to enter specific data and calculate the final grade. Here is code which I modified from an earlier post from Philip M. Code: <script type = "text/javascript"> var count = 1; var total = 0; var info= new Array(); var numGrades = 2; for (var i = 0; i<numGrades; i++) { var repeat = true; while(repeat) { var ans = parseInt (prompt("Enter grade between 0%-100% for Grade # "+ count,"")); if ((isNaN(ans)) || (ans == null) || (ans < 1) || (ans > 100)) { alert ("You must enter a number between 0 and 100"); } else { repeat = false; count ++; info[i] = ans; total = total + info[i]; } } } var avg = total/info.length; for (var i = 0; i < info.length; i++) { document.write("Grade " + (i+1) + " Marks = " + info[i] + "<br>"); } document.write("<br> Average Mark = " + avg.toFixed(2)) </script> Here is the hard part: I am trying to make it so it will first ask how many grades to be calculated rather than a fixed grade. Then it will ask for grade 1 how many grades to be calculated for grade 1 and there percentage. Example: (alert box) How many overall grades to be calculated? User types 2 (alert box) Grade1 how many quizzes to be calculated? User types 2 (alert box) quiz 1 how much percent is this worth out of 100%? User types 80% (alert box) What grade did you receive? (alert box) quiz2 how much percent is this worth out of 100%? User types 20% (alert box) What grade did you receive? (alert box) Grade2 how many quizzes to be calculated? User types 1 (alert box) quiz 1 how much percent is this worth out of 100%? User would type 100% (alert box) What grade did you get? And then the results should look something like this: Grade 1 you got an 86% Grade 2 you got an 91 Final grade = ….. This is probably just a dumb way of doing this so anyway which will get the same result will be fine. I'm not sure if alert box is the wrong way to go. Trying to put my finger on how to achieve this result. About half way down on the page linked below you'll see "Recent - Comments - Popular - Tags" this table expands when you rollover and stays expanded while allowing you to populate the different content. Any help would be greatly appreciated, not even sure if I'm in the right forum. http://thedailydisney.com/blog/2010/...magic-kingdom/ Thanks for the time. Will I am building an elearning site where the user is taken through a series of dynamically driven pages to refine their choices. I am using php amd mysql to populate a series of tables but on the last page the table gets very long so i am trying to make the table expandable. I found this and this on http://www.javascripttoolbox.com/jquery/ and it's proving helpful but i need a little help taking it a step further. I also found this to be useful for anyone else who is trying to do the same thing: http://www.jankoatwarpspeed.com/post...nd-plugin.aspx FROM JAVASCRIPTTOOLBOX A common UI is to have a table of data rows, which when clicked on expand to show a detailed breakdown of "child" rows below the "parent" row. The only requirements a 1. Put a class of "parent" on each parent row (tr) 2. Give each parent row (tr) an id 3. Give each child row a class of "child-ID" where ID is the id of the parent tr that it belongs Original code: Code: $(function() { $('tr.parent') .css("cursor","pointer") .attr("title","Click to expand/collapse") .click(function(){ $(this).siblings('.child-'+this.id).toggle(); }); $('tr[@class^=child-]').hide().children('td'); }); This works great but my parent and child rows all contain checkboxes and If i try and check the checkboxes in the master rows the child rows associated with that master row expand and contract. I have added an extra cell to each row and i'm using a css class to add an arrow image to each master row but i am new to Javascript so i am not sure what i am doing. My code now looks like this: Code: $(document).ready(function() { $('tr:not(.parent)').hide(); //$('tr.parent') $('.arrow') .css("cursor","pointer") .attr("title","Click to expand/collapse") .click(function(){ $(this).siblings('.child-'+this.id).toggle(); $(this).toggleClass("up"); }); }); So far the arrow image is toggling but i can't seem to work out how to get the .click function to affect the whole row and not just the image. Can anybody help me? Thanks Hi, How I build a table based on a list under a <DIV></DIV> like this? printing: 1 and: 3 typesetting: 2 industry: 2 has: 2 been: 1 s: 1 standard: 1 ever: 1 since: 1 1500s: 1 when: 1 an: 1 unknown: 1 printer: 1 took: 1 a: 2 galley: 1 type: 3 scrambled: 1 Regards Bob Good morning! I am Brazilian, sorry if there is a clerical error because I used the Google translator. I'm having trouble recovering in JS content of the columns of a <TABLE>. I did many searches but found nothing that could help me. I appreciate any help. Thank you! Manoel Zancheta I am building an e-learning lesson in Lectora that will be deployed to a SCROM compatible learning management system. The lesson is converted into HTML before that happens. My table of contents is around 100 pixels wide but some of the page names are longer than that and do not display fully when viewed in a browser. What I am trying to do is this: The page name for this page is very, very long and I can't see it all. Blah blah Would become The page name for this page is very, very long and I can't see it all. Blah blah I've been led to believe there is javascript that will do that. Hi I want to get javascript to show or hide a row in a table depending on whether a value is held by a variable collected in a mulitple part formmail. If only 1 adult fills in their name on the earlier form there is no need to show the row which asks him to agree to membership on a later form page. This is what Ive got so far Code: <form name="frm3" method="post" action="bookingscript.php"> <input type="hidden" name="adult2fn" value="$adult2name" /> <script Language="JavaScript"> var name1 = document.frm3.adult2fn.value; if(name1 =="") {alert("hello");document.getElementById("hidden_row").style.display = 'none';} else {alert("no way");document.getElementById("hidden_row").style.display = '';}; </script> <table border="1"> <tr> <td>Always visible</td> </tr> <tr id="hidden_row"> <td>Hide this</td> </tr> <tr> <td>Always visible</td> </tr> </table> </form> If $adult2name is blank then name1 is blank and the row does not show, else $adult2name contains a name, name1 is not blank and the row shows. I have tried displaying the hidden form field (by changing it to text), and adding my own content, also putting in my own values instead if $adult2name and the Alerts appear as appropriate, but the whole table disappears whilst the alert is on and reappears when the alert is OKed for either condition of the if. Same in Firefox and IE7 & 8 Could someone please tell me the error of my ways. Many thanks Richard Hi all, What I am trying to achieve. I have a php page that has a button on it when clicked shows a div (previously hidden) in the middle of the page this div contains a table with rows. Each row has an image acting as a button and a series of fields that are populated from a database. One of the fields is a quantity box I want to be able to change the value in this box and click on the submit img and have it submit this info (including the altered quantity) back to the php page or to the submit function so that I can then access the values. I have absolutly no idea how to start this. I have very limited javascript experience. the submit looks something like (at the moment) Code: echo '<a href="#" onclick="javascript: document.getElementById(\'stockitemid\').value = '.$stockline->purchaseitemid.'; submitbutton(\'addLineFromStock\')" >'.$purchaseLineImg.'</a>'; and then I was trying to alert in the submit function something like: Code: alert(document.getElementById('stockitemid').value); my div td fields look like Code: <td> <input type="text" size="3" name="sid[<?php echo $stockline->purchaseitemid; ?>]" id="stockitemid<?php echo $count; ?>" value="<?php echo $stockline->purchaseitemid; ?>" /> </td> <td> <input type="text" size="3" name="stockqty[<?php echo $stockline->purchaseitemid; ?>]" id="stockquantity" value="<?php echo $stockline->quantitysupplied; ?>" /> </td> Any help would be greatly appreciated Thanks Kate I am working on a project where I have 5 XML files that I bring into HTML and display the tables on one browser page. I would like for the row of the tables to change depending on what is in the "status" field. There will only be the following inputs in that column - "IS" which is in stock(green), "OS" which is out of stock(red), and "PO" which is Pre-Order(blue). Code: !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>ABC Book Store</title> <style type="text/css"> <!-- .style1 { font-size: 10pt; } --> </style> <script> function ld_fiction() { var doc=nb_fiction.XMLDocument; doc.load("fiction.xml"); document.getElementById("head_id").innerHTML="Fiction "; } function Id_nfiction() { var doc_s=nb_nfiction.XMLDocument; doc_s.load("nfiction.xml"); document.getElementByID("head_id_d").innerHTML="NonFiction"; } function ID_selfhelp() { var doc_t=nb_selfhelp.XMLDocument; doc_t.load("selfhelp.xml"); document.getElementByID("head_id_e").innerHTML="SelfHelp"; } function ID_reference() { var doc_u=nb_ref.XMLDocument; doc_u.load("ref.xml"); document.getElementByID("head_id_f").innerHTML="Reference"; } function ID_mags() { var doc_v=nb_mags.XMLDocument; doc_v.load("mags.xml"); document.getElementByID("head_id_g").innerHTML="Mags"; } </script> <XML id="nb_fiction" src="fiction.xml"></XML> <XML id="nb_nfiction" src="nfiction.xml"></XML> <XML id="nb_selfhelp" src="selfhelp.xml"></XML> <XML id="nb_ref" src="ref.xml"></XML> <XML id="nb_mags" src="mags.xml"></XML> <object id="nb_fiction" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" width="0" height="0"></object> <object id="nb_nfiction" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" width="0" height="0"></object> <object id="nb_selfhelp" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" width="0" height="0"></object> <object id="nb_ref" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" width="0" height="0"></object> <object id="nb_mags" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" width="0" height="0"></object> <body> <table width="30%" border="0" align="left" cellspacing="1" font size="10"> <tr bgcolor="#CCCCCC"> <td colspan="2"> <table id="FICTIONTABLE" table width="100%" datasrc="#nb_fiction" font size="1" border="0" align="center" bordercolor="#FFFFFF"> <caption> <span>Fiction </span> </caption> <thead> <tr> <th span class="style1">Stock No.</th></span> <th span class="style1">Title</th></span> <th span class="style1">Author</th></span> <th span class="style1">Status</th></span> <th span class="style1">Price</th></span> <th span class="style1">Publisher</th></span> <th span class="style1">Year of Release</th></span> </tr> </thead> <tbody> <tr> <td><span class="style1" datafld="stock"></td></span> <td><span class="style1" datafld="title"></td></span> <td><span class="style1" datafld="author"></td></td></span> <td><span class="style1" datafld="status"></td></span> <td><span class="style1" datafld="price"></td></span> <td><span class="style1" datafld="publisher"></td></span> <td><span class="style1" datafld="year"></td></span> </tr> </tbody> </table> </td> </tr> </body> </html> I only included the first part of the html code along with the first table, but there is a table for each xml file. You can also probably tell how the XML files are structured by looking at the way they are displayed in the tables. I think what I want to do can be accomplished with JavaScript, but I have no idea how to do it and it's the only thing I have left before I'm done. Any help would really be appreciated and thanks in advance. I have to create a function that uses infoMenu(), and I am having a hard time with this. I have created a loadInfo() function, and I am supposed to follow the same steps, but for some reason I am not getting it. Below is an example of what I have done already. Code: function loadInfo(myForm) { var menuSelect=myForm.Menu.selectedIndex var menuUrl=myForm.Menu.options[menuSelect].value+".html" window.location=menuUrl } This is what I placed in my select tag to in order to go to the pages once they were selected. Code: <select name="Menu" onchange="loadInfo(this.form)"> What i am trying to do is create the infoMenu() function that uses the selectedIndex value of the moreInfo <select> list in the menuInfo<form>. Any help would be greatly appreciated Hello there, I'm a 30yr old returning to school and I signed up for a CMIS102 class, thinking it be more explanatory as the syllabus let on. But I was wrong. While I do understand some of what the professor has been teaching us, like modular programming and IfElse statements, I can't wrap my head around things like While Loops. My professor has saddled us with a couple assignments, requiring us to write in pseudocode and I was wondering if anyone could explain what he wants from this assignment or even help me with it, that maybe I can finally have a grasp of it, and will know what I'm doing on the final. ~Tia P.S. I've posted the assignment question below: I need to write a pseudo-codepseudocode for the following question but don't know how: Write a program to read a list of exam scores (in the range 0 to 100) and to output the total number of grades and the number of grades in each letter=grade category. The end input is indicated by a negative score as a sentinel value. (The negative value is used only to end the loop, so do not use it in the calculations. Example: 88 93 55 77 100 -1 (The output would be) Total number of grades = 5 Number of A's =2 Number of B's = 1 Number of C's =1 Number of D's = 0 Number of F's =1 Must prompt user to run again This post is going to seem long because of the coding in it, but the solutions I need are simple. BASICALLY I need to know: 1) where to use the if's and else's 2)how to call the boolean method isEmpty() from the CanOfCoke class 3)how to apply methods from the other classes to the machine, bin, and can variables 4) how to check to see if an ArrayList has any content (ie if the student has any coins or not) This is complicated for me to complain because I'm a complete n00b and this is my first Java class, but I hope someone can help me because my teacher isn't all that great at explaining things. and I'm stuck on the LAST method of the LAST class of our FINAL project lol. The project has 5 classes: Coin DrinksMachine CanOfCoke GarbageDisposalUnit Student I am working on the Student class and here is the code I have so far: Code: import java.util.ArrayList; /** * Write a description of class Student here. * * @author xxx * @version Project part 5 */ public class Student { private String name; private ArrayList purse; private boolean sobbing; private DrinksMachine machine; private GarbageDisposalUnit bin; private CanOfCoke can; /** * Constructor for objects of class Student * * @ param pName The name of the studen * @ param nCoins The number of coins the student has */ public Student(String pName, int nCoins) { name = pName; purse = new ArrayList<Coin>(nCoins); sobbing = false; machine = null; bin = null; can = null; } /** * This method will set the students machine variable * * @param name of the machine */ public void setMachine(DrinksMachine aMachine) { machine = aMachine; } /** * This method will set the students garbage disposal unit * * @param name of the garbage disposal unit */ public void setBin(GarbageDisposalUnit aBin) { bin = aBin; } /** * This method will print out information about the student * */ public void displaySelf() { if (can == null) { System.out.println(name + " does not have a can of Coke."); } else { System.out.println(name + " has a can of Coke."); } if (sobbing == true) { System.out.println(name + " is sobbing."); } else { System.out.println(name + " is not sobbing."); } System.out.println(name + " has" + purse.size() + " coins in their purse."); } /** * This method will perform the actions of: * * If they have a can of coke: * The student takes a single sip from a can of Coke and puts it in the trash bin when empty. * * If they don't have a can of coke: * The student inserts a coin and obtain the can of coke and take a sip from it. * * If they can't get a can of coke: * The student sobs. * */ public void doAction() { if (can != null) { can.giveSip(); } else if (can.isEmpty()) { bin.addCan(bi); can = null; } else { if (purse != null && can != isEmpty()) { machine.insertCoin(); machine.deliverCan(); can.open(); can.giveSip(); } else { sobbing = true; } } } } This is the part I am having troubles with: [CODE public void doAction() { if (can != null) { can.giveSip(); } else if (can.isEmpty()) { bin.addCan(bi); can = null; } else { if (purse != null && can != isEmpty()) { machine.insertCoin(); machine.deliverCan(); can.open(); can.giveSip(); } else { sobbing = true; } } } } [/CODE] Here are his horrible instructions: a method with signature public void doAction() which performs the following actions: i. if the Student has a can of Coke then they take a single sip from it. If it becomes empty they put it in the bin, and cease to hold it (i.e. can is set to null). The doAction() method then exits. ii. if the Student does not have a can of coke then they insert a Coin(if they have one) into the coke machine (if it isn't empty), take the can of Coke they have paid for, and take a sip from it (after opening the can). If for any reason they are unable to get a can of Coke (machine empty, or no Coins) they begin to sob. iii. Pseudo-code for this is shown below: IF the student has a can THEN take a sip IF the can is now empty THEN add it to the bin OTHERWISE (i.e. the student does not have a can to start with) IF the student has a Coin AND the machine is not empty THEN insert a Coin into the machine reduce Coins by one get the can from the machine open the can and take a sip OTHERWISE student starts sobbing Hi, I would like to create a calculator which can help parents when they calculate their student's school fees on our school's joomla web site. Ive attached our school's fee table. Is there anyone who can help me please? Regards Hi, I'm completely new to using JavaScript having never used it before so please forgive me if this is ridiculously easy to solve. I want to include an expandable FAQ section in part of my website. I managed to find some code that works however by default the sections are expanded. I want them to automatically be collapsed when the page loads and when you click the image it then expands and shows the hidden text. The code I found is Code: <head><title> Untitled Page </title> <script type="text/javascript"> function expandable_toggle(id) { var tr = document.getElementById(id); if (tr==null) { return; } var bExpand = tr.style.display == ''; tr.style.display = (bExpand ? 'none' : ''); } function expandable_changeimage(id, sMinus, sPlus) { var img = document.getElementById(id); if (img!=null) { var bExpand = img.src.indexOf(sPlus) >= 0; if (!bExpand) img.src = sPlus; else img.src = sMinus; } } function Toggle_trGrpHeader1() { expandable_changeimage('trGrpHeader1_Img', 'images/minus.gif', 'images/plus.gif'); expandable_toggle('trRow1'); } function Toggle_trGrpHeader2() { expandable_changeimage('trGrpHeader2_Img', 'images/minus.gif', 'images/plus.gif'); expandable_toggle('row1'); } </script> </head> <body> <div> <table border="0"> <tr id="trGrpHeader1"> <td colspan="4"><span onclick="javascript:Toggle_trGrpHeader1();"><img src="images/minus.gif" id="trGrpHeader1_Img"/>Pretend this is a header for row 1</span></td> </tr> <tr id="trRow1"> <td> Hello<br><br></td></tr> <tr id="trGrpHeader2"><td colspan="4"><span onclick="javascript:Toggle_trGrpHeader2();"><img src="images/minus.gif" id="trGrpHeader2_Img"/>Pretend this is a header</span></td> </tr> <tr id="row1"> <td> 123</td></tr> </table> </div> </body> </html> Any help you can give would be greatly appreciated. Many thanks Hey guys, I own an online internet radio station and I have many different way which people can tune in. One way is the browse 'n' play feature. The browse 'n' play feature allows you to browse the net at the same time as being tuned into the radio. Below, I have installed an 'Expandable Sticky Bar' which is used for the radio panel. http://www.dynamicdrive.com/dynamici.../stickybar.htm What I am trying to do, is simply add that bar on every page my visitors visit. So, when the listen chooses 'Browse 'n' Play' I want a new window or tab to open, with Google and my bar at the bottom. I cannot figure out how I could do this, any ideas on how I could make this happen? Thanks. I just got this problem when I try to add the expandable divs in my webpage. However when I click the divs on the page, I can't see the rest of my content. This is my page, does anybody know what happened with my code??!! http://www.calibredesign.com/clients..._news_new.html the divs are on the button of the page. Thanks!! hi, i got a expandable menu that is working. i wonder if there is any way to make the links show as html and css if the user has disabled javascript i my code including javascript and css <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script language="JavaScript" type="text/JavaScript"> <!-- menu_status = new Array(); function showHide(theid){ if (document.getElementById) { var switch_id = document.getElementById(theid); if(menu_status[theid] != 'show') { switch_id.className = 'show'; menu_status[theid] = 'show'; }else{ switch_id.className = 'hide'; menu_status[theid] = 'hide'; } } } //--> </script> <style type="text/css"> .menu1{ margin-left:25px; padding-left:20px; padding-top:2px; padding-bottom: 2px; display:block; text-decoration: none; color: #000000; height: 20px; width: 200px; background-color: #03C; border: thin solid #FFF; } .submenu{ background-image: url(images/submenu.gif); display: block; height: 19px; margin-left: 38px; padding-top: 2px; padding-left: 7px; color: #333333; } .hide{ display: none; } .show{ display: block; } </style> </head> <body> <a class="menu1" onclick="showHide('mymenu1')">Menu 1</a> <div id="mymenu1" class="hide"> <a href="#" class="submenu">Link One here</a> <a href="#" class="submenu">Link Two here</a> <a href="#" class="submenu">Link Three here</a> <a href="#" class="submenu">Link Four here</a> </div> <a class="menu1" onclick="showHide('mymenu2')">Menu 2 </a> <div id="mymenu2" class="hide"> <a href="#" class="submenu">Link One here</a> <a href="#" class="submenu">Link Two here</a> <a href="#" class="submenu">Link Three here</a> <a href="#" class="submenu">Link Four here</a> </div> <a class="menu1" onclick="showHide('mymenu3')">Menu 3 </a> <div id="mymenu3" class="hide"> <a href="#" class="submenu">Link One here</a> <a href="#" class="submenu">Link Two here</a> <a href="#" class="submenu">Link Three here</a> <a href="#" class="submenu">Link Four here</a> </div> <a class="menu1" onclick="showHide('mymenu4')">Menu 4 </a> <div id="mymenu4" class="hide"> <a href="#" class="submenu">Link One here</a> <a href="#" class="submenu">Link Two here</a> <a href="#" class="submenu">Link Three here</a> <a href="#" class="submenu">Link Four here</a> </div> <a class="menu1" onclick="showHide('mymenu5')">Menu 5 </a> <div id="mymenu5" class="hide"> <a href="#" class="submenu">Link One here</a> <a href="#" class="submenu">Link Two here</a> <a href="#" class="submenu">Link Three here</a> <a href="#" class="submenu">Link Four here</a> </div> </body> </html> Hey, I have a drop down box that selects a project name. This is then taken to a javascript function that is supposed to fill in a read-only box with that name, but instead of filling it in with the project name, it fills it in with the project ID, which is how the sql database is set up. Each project has an ID, a name, and other values. Is there a way I can get the project name given the project ID in the javascript function?
|