kurt.santo Posted October 15, 2007 Share Posted October 15, 2007 With regard to post "Great cross-browser working dynamic sidebar" I would like to automatically assign the <strong> element instead of hard-coding it into each page. How would you do this? I will do the nav bar with HTML only (no database yet). I will change this later on. For now, I do not want to over-complicate matters for my learning curve;-)KurtBTW: Again with reference to my other post, the mentioned book is great (although some is really above my head right now). I found that other code samples on the internet sometimes do not work properly with my browsers, which adds to my confusion. The book seems to cater for all browser problems and has a lot of great code samples in it. Link to comment Share on other sites More sharing options...
aspnetguy Posted October 15, 2007 Share Posted October 15, 2007 Do you mean you want to remove <strong> from the html code and dynamically place it around "Products"? Link to comment Share on other sites More sharing options...
kurt.santo Posted October 15, 2007 Author Share Posted October 15, 2007 Do you mean you want to remove <strong> from the html code and dynamically place it around "Products"?In a perfect world I would not hardcode the strong element into any page. For the third level in the menu structure (the levels above can be hard-coded as there won't be too many) I would like to have links for all entries in the nav bar, but the current page's link should be replaced with a strong element (if possible???)... They actually refer all to the same php page (called products). I pass the nav bar entry in the form products.php?id=36 (still, obviously the user has to know onto which item he clicked). Can this be done with JavaScript at all?Kurt Link to comment Share on other sites More sharing options...
jesh Posted October 16, 2007 Share Posted October 16, 2007 I, personally, would use styles to make the text bold: var link = document.getElementById("mylink");link.style.fontWeight = "bold"; But, you could also do something like this: var link = document.getElementById("mylink");var html = "<strong>" + link.innerHTML + "</strong>";link.innerHTML = html; Link to comment Share on other sites More sharing options...
kurt.santo Posted October 16, 2007 Author Share Posted October 16, 2007 I, personally, would use styles to make the text bold:var link = document.getElementById("mylink");link.style.fontWeight = "bold"; But, you could also do something like this: var link = document.getElementById("mylink");var html = "<strong>" + link.innerHTML + "</strong>";link.innerHTML = html; That makes sense. But how do you assign id "mylink" automatically to current page? There lies my problem Kurt Link to comment Share on other sites More sharing options...
aspnetguy Posted October 17, 2007 Share Posted October 17, 2007 You'll have to assign some identifying marker at some point. If you do not want to do it for each link you could use getElementsByTagName with a little creativity. Link to comment Share on other sites More sharing options...
kurt.santo Posted October 17, 2007 Author Share Posted October 17, 2007 What do you exactly mean by "a little creativity"? If I use getElementsByTagName it will return all links, won't it?Kurt Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.