Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Newbie question
- From: Shawn at Milochik.com (Shawn Milo)
- Subject: [Javascript] Newbie question
- Date: Thu Dec 1 12:51:51 2005
Schalk,
You're in luck. As it turs out, I threw something like this together just
last week. I have a page which I want to show only information for North
America, Europe, or Japan -- depending on the user's preference.
I just create objects with an ID ending in _na, _eu, or _jp. Then I use the
following code to make the magic happen. I hope you find it useful. I cut
out some extra stuff which has to do with cookies. You won't be needing it
for an order form, but I want my users to get what they want to see without
selecting it each time.
If anyone wants the cookie stuff, just let me know. I'm not withholding it
for any reason other than to make the remaining code as clear as possible.
Milo
function customizePage(rbuc){
for (x=0;x<document.all.length;x++){
docID = document.all[x].id;
//match on something ending in an underscore then two letters
if (document.all[x].id.match(/^.*_[a-z]{2}$/)){
//if it matches the rbuc passed to the function, make it
visible
//else, make it invisible
if (docID.substr(docID.length -2,2) != rbuc){
document.all[x].style.display = "none";
}else{
document.all[x].style.display = "block";
}
}
}
}
function defaultRBUC(){
var rbuc = '';
rbuc = readCookie('rbuc');
if (rbuc == ''){
rbuc = 'na';
}
customizePage(rbuc);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.LaTech.edu/pipermail/javascript/attachments/20051201/6a61a7dc/attachment.html
- References:
- [Javascript] Newbie question
- From: Schalk
- [Javascript] Newbie question
- Prev by Date: [Javascript] Newbie question
- Next by Date: [Javascript] Newbie question
- Previous by thread: [Javascript] Newbie question
- Next by thread: [Javascript] Newbie question
- Index(es):