By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

Big menu

P: n/a
Hello all,

i'm generating a select menu, with php/mysql. The menu contains country names.

My problem is that i have ~ 250 countries in one of these menu and i need from
6 to ten times this menu in a web page.

Is there any way for sharing the data between each menu? It should speed up
transfert and decrease size of the web page.

Thx

--
David

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
david <pa*********@server.com> writes:
i'm generating a select menu, with php/mysql. The menu contains
country names.

My problem is that i have ~ 250 countries in one of these menu and i
need from 6 to ten times this menu in a web page.
Whoa. with 250 options in a select element, you might want to consider
other ways of choosing (not sure which would be better, though, 250
options is a lot).
Is there any way for sharing the data between each menu? It should speed up
transfert and decrease size of the web page.


Yes, but then your page will not work if Javascript is disabled.
---
<script type="text/javascript">
function copyOptions(idFrom,idTo) {
var from = document.getElementById(idFrom);
var to = document.getElementById(idTo);
// maybe add sanity check: does both exist and are select elements
to.length = 0;
for (var i=0;i<from.length;i++) {
var opt = from.options[i];
to.options[i]=new Option(opt.text,opt.value);
}
}

function init() {
copyOptions("countrySel1","countrySel2");
copyOptions("countrySel1","countrySel3");
copyOptions("countrySel1","countrySel4");
copyOptions("countrySel1","countrySel5");
copyOptions("countrySel1","countrySel6");
}
</script>
---
and
---
<body onload="init()">
... <select id="countrySel1"><option>x250...</select>
... <select id="countrySel2"></select>
... <select id="countrySel3"></select>
---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
Lasse Reichstein Nielsen wrote:
david <pa*********@server.com> writes:
i'm generating a select menu, with php/mysql. The menu contains
country names.

My problem is that i have ~ 250 countries in one of these menu and i
need from 6 to ten times this menu in a web page. Whoa. with 250 options in a select element, you might want to consider
other ways of choosing (not sure which would be better, though, 250
options is a lot).
well, a select your country menu is widely present on the web though...

Is there any way for sharing the data between each menu? It should speed up
transfert and decrease size of the web page.

Yes, but then your page will not work if Javascript is disabled.
that's already the case :(

---
<script type="text/javascript">
function copyOptions(idFrom,idTo) {
var from = document.getElementById(idFrom);
var to = document.getElementById(idTo);
// maybe add sanity check: does both exist and are select elements
to.length = 0;
for (var i=0;i<from.length;i++) {
var opt = from.options[i];
to.options[i]=new Option(opt.text,opt.value);
}
}

function init() {
copyOptions("countrySel1","countrySel2");
copyOptions("countrySel1","countrySel3");
copyOptions("countrySel1","countrySel4");
copyOptions("countrySel1","countrySel5");
copyOptions("countrySel1","countrySel6");
}
</script>
---
and
---
<body onload="init()">
... <select id="countrySel1"><option>x250...</select>
... <select id="countrySel2"></select>
... <select id="countrySel3"></select>
---


thx but with this, the size of the web page is smaller, but the HTML tree in
the browser memory ends up with the same size... it's not exactely what i
wanted but, i may use the trick later.

Thx again :)

--
David

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.