473,486 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Create 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(event)
// 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(event)
{
// get parent-Button-id
var obj = event.target;
var targetId = obj.id;
var idPostfix = targetId.charAt(1);
var idBase = parseInt(targetId);
//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)+idPostfix; // from variables ???

bTemp.style.position = 'relative';
bTemp.style.left = obj.style.left;
bTemp.style.top = (parseInt(obj.style.top)+(25*(i+1)))+'px';
bTemp.style.width = 100+"px";
bTemp.style.backround = bgImg;
document.getElementById(targetId).appendChild(bTem p);
}

var mesg = '';
// mesg += 'this.id = '+pBid;
mesg += '\ntarget Id = '+targetId;
mesg += '\ntarget Id as int= '+parseInt(targetId);
mesg += '\nbTemp Id = '+bTemp["id"];
mesg += '\nidPostfix = '+idPostfix;
mesg += '\nidBase = '+idBase;
mesg += '\nobj.style.left = '+obj.style.left;
mesg += '\nobj.style.top = '+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 1950
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(event)
// 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(event)
{
// get parent-Button-id
var obj = event.target;
var targetId = obj.id;
var idPostfix = targetId.charAt(1);
var idBase = parseInt(targetId);
//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)+idPostfix; // from variables ???

bTemp.style.position = 'relative';
bTemp.style.left = obj.style.left;
bTemp.style.top = (parseInt(obj.style.top)+(25*(i+1)))+'px';
bTemp.style.width = 100+"px";
bTemp.style.backround = bgImg;
Wrong spelling, should be:

bTemp.style.background = 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.getElementById(targetId).appendChild(bTem p);
}
<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
4648
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...
8
3235
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...
12
8483
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...
26
2802
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...
2
2083
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...
4
13015
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...
4
8331
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...
2
2267
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...
21
2354
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...
0
7100
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,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
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...
0
7330
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...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
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...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
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...
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.