473,549 Members | 2,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

programmatic menu - disappearing divs


Hi all.

I've been here before and got a lot of help with my neophyte troubles so I'm
back again.

This time I have a number of questions (if I can remember them all).

(I've pasted the code in question at the end of this message and installed it on
the web at http://www3.telus.net/bikim/test .)

Just for something to do I'm attempting to code a menu system that is as
programmable as I can. The first row, that I call the 'base buttons' works
mostly like I expect it to.

Q1: The problem I am having is that when I click a base button to generate a
column of similar buttons nothing appears. According to the dom inspector the
divs are being created but they just don't appear anywhere that I can find.

Q2: How can I align the text vertically in the div?

Q3: What were the rest of my questions?

------- start of code --------

// FUNCTION :: makeButtons(eve nt)
// this handles the onclick event in a base button
// i.e. onclick = makeButtons
// Use :: supply num 'buttons'
// Receives :: number of buttons to make as int <from button clicked?>
// :: type of container to use
// Returns :: status as bool

function makeButtons(eve nt)
{
// get parent-Button-id
var obj = event.target;
var targetId = obj.id;
var idPostfix = targetId.charAt (1);
var idBase = parseInt(target Id);
//var iD = this.id;
for(var i=0; i<=rows; i++) // get rows from functions.js
{
var bTemp = makeEl('div'); // button temp

bTemp['id'] = (i+idBase+1)+id Postfix; // from variables ???

bTemp.style.pos ition = 'relative';
bTemp.style.lef t = obj.style.left;
bTemp.style.top = (parseInt(obj.s tyle.top)+(25*( i+1)))+'px';
bTemp.style.wid th = 100+"px";
bTemp.style.bac kround = bgImg;
document.getEle mentById(target Id).appendChild (bTemp);
}

var mesg = '';
// mesg += 'this.id = '+pBid;
mesg += '\ntarget Id = '+targetId;
mesg += '\ntarget Id as int= '+parseInt(targ etId);
mesg += '\nbTemp Id = '+bTemp["id"];
mesg += '\nidPostfix = '+idPostfix;
mesg += '\nidBase = '+idBase;
mesg += '\nobj.style.le ft = '+obj.style.lef t;
mesg += '\nobj.style.to p = '+obj.style.top ;
mesg += '\nbTemp.style. top = '+(parseInt(obj .style.top)+25) +'px';

alert('In makeButtons \n'+mesg);
return 'false';
}
// end of FUNCTION :: makeButtons()

---------- End of Code Snippet ----------
Thanks
--

Phil Newcombe - philn?telus?net

http://www3.telus.net/bikim

Jul 20 '05 #1
1 1962
Phil N wrote:

Hi all.
<snip>

(I've pasted the code in question at the end of this message and
installed it on the web at http://www3.telus.net/bikim/test .)

Just for something to do I'm attempting to code a menu system that is as
programmable as I can. The first row, that I call the 'base buttons'
works mostly like I expect it to.

Q1: The problem I am having is that when I click a base button to
generate a column of similar buttons nothing appears. According to the
dom inspector the divs are being created but they just don't appear
anywhere that I can find.

Q2: How can I align the text vertically in the div?
Um, "text-align: center;" and line breaks?
This may not be the question :)

------- start of code --------

// FUNCTION :: makeButtons(eve nt)
// this handles the onclick event in a base button
// i.e. onclick = makeButtons
// Use :: supply num 'buttons'
// Receives :: number of buttons to make as int <from button clicked?>
// :: type of container to use
// Returns :: status as bool

function makeButtons(eve nt)
{
// get parent-Button-id
var obj = event.target;
var targetId = obj.id;
var idPostfix = targetId.charAt (1);
var idBase = parseInt(target Id);
//var iD = this.id;
for(var i=0; i<=rows; i++) // get rows from functions.js
{
var bTemp = makeEl('div'); // button temp

bTemp['id'] = (i+idBase+1)+id Postfix; // from variables ???

bTemp.style.pos ition = 'relative';
bTemp.style.lef t = obj.style.left;
bTemp.style.top = (parseInt(obj.s tyle.top)+(25*( i+1)))+'px';
bTemp.style.wid th = 100+"px";
bTemp.style.bac kround = bgImg;
Wrong spelling, should be:

bTemp.style.bac kground = bgImg;
Text color seems to inherit from the value #ffffff set in
applyBaseLabels , so without the background, any text inserted in the
bTemp appears white on white and causes test confusion.
document.getEle mentById(target Id).appendChild (bTemp);
}
<snip>
return 'false';
Recall function comment: // Returns :: status as bool

'false' with quotes is a string value, as is 'true'. Both will test
boolean true in a javascript conditional. To return boolean values, omit
the quotes:

return true; // or
return false; }
// end of FUNCTION :: makeButtons()


Major comment - HTML id values should start with a letter:

<cite>
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".").
</cite>

The code works in Mozilla, but you may wish to look into it.
Good luck,
Dom

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4662
by: Rob McLennan - ZETLAND | last post by:
Hi, I have set up an external stylesheet, named "print.css", to format the style of all pages printed from my company's website. I've been previewing my changes to the stylesheet by doing File\Print Preview in IE6 and noticed that occasionally the leftmost button of the javascript menu (CoolMenus Version 3.02) on our website is printed. (I...
8
3240
by: Rob McLennan - ZETLAND | last post by:
Hi, I have set up an external stylesheet, named "print.css", to format the style of all pages printed from my company's website. I've been previewing my changes to the stylesheet by doing File\Print Preview in IE6 and noticed that occasionally the leftmost button of the javascript menu (CoolMenus Version 3.02) on our website is printed. (I...
12
8487
by: Kyle James Matthews | last post by:
Hello, I have been lurking here for a little bit (truth be told, I lurk on too many newsgroups to be truly effective). I have made a CSS rollover menu, and would like some advice. The menu is at the URL http://www.digitalovertone.com/index3.php. You will notice that the each link disappears the first time you hover over it (this is most...
26
2808
by: Thomas Mlynarczyk | last post by:
Hi, Could some kind person using Mac or Linux (or others) please take a look at http://www.mlynarczyk-webdesign.de/tmp/menu/menu.html and tell me if the page renders as it should (screenshot provided on the page)? Never mind the colors, this is just to test the functionality. The page validates (HTML & CSS), and seems to "work" as...
2
2090
by: george.leithead | last post by:
Hi all, I have a very strange problem! In following Web page (which is generated from a CMS System), the navigation to the left 'dissapears' when you roll the mouse over the links? It does not do this in all browsers either. I have found it to happen in IE 7 and the latest patched IE 6. I have tried to find out the reason, but keep...
4
13019
by: fizzyfozzy | last post by:
Hi, I am trying to figure out how to show or hide a selection of divs on my page depending on what is selected from a list/menu item, using css & javascript. I have tried to use the script listed here: http://www.thescripts.com/forum/thread88791.html but have been uable to customise it to my needs and could do with some help. My form is...
4
8341
by: Rabel | last post by:
I am not very good at javascript I mostly am a flash developer but I am trying to apply one of our old expanding menus to work for a new site but it doesn't collapse the way I need it to right now the code I am using looks like this function openSubCategory(n, nn) { var i = 0 for(i=1;i<n+1;i++) { var sel =...
2
2281
by: insanity | last post by:
Can anyone help me with a problem that I have with apparently unrelated text disappearing in IE7 when I set a className. This does not happen in Firefox. I am trying to create an Ajax driven table where you can click on an active cell to pop up a form, then submit that form to modify the cell value. My page uses several layers of tables and...
21
2368
by: daydream | last post by:
yeah i need some help(such a common line) ,i have a menu and each link has its own div respectively and yeah obviously when u click the link the div shows, the problem is i would like each div to show no matter how many times you click the link for it and if you click on another one and when u go back to the original , the div would still show. at...
0
7527
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7459
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7726
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7485
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7819
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5377
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3488
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.