[Javascript] Javascript arrays
Terry Riegel
riegel at clearimageonline.com
Thu May 6 05:30:47 CDT 2004
Hello,
I am new to javascript and would like to convert my code from a brute
force method to a simpler method. I hope someone can help me out.
First let me say I am very inexperienced in Javascript, not
programming. So consequently I can understand concepts pretty well, but
struggle with the simple syntax issues.
Here is part of the function:
function changedest(dest,type)
{
var td = document.getElementById(dest);
if (td.style.backgroundColor == '#BFD7FF')
{
td.style.backgroundColor = '#FFFFFF';
document.browseform["fm_list"].value =
document.browseform["fm_list"].value.replace("|"+dest,"");
}
else
{
td.style.backgroundColor = '#BFD7FF';
document.browseform["fm_list"].value =
document.browseform["fm_list"].value+"|"+dest;
}
}
The hidden field will contain the list of selected items like and gets
updated when a user clicks on a link if its in the list it gets
removed, if not it gets added. The problem is I am using the background
color to determine the status of the list, and there are situatiuons
when the background color and the list are out of sync. I would like to
create a way for the background color to be set from the list, but I
have no idea how to proceed. I have created a deselect() function, but
it is very crude. Here it is.
function deselect()
{
var td = document.getElementById('.TEMP');
td.style.backgroundColor = '#ffffff';
var td = document.getElementById('app');
td.style.backgroundColor = '#ffffff';
var td = document.getElementById('apps');
td.style.backgroundColor = '#ffffff';
etc...
}
Thanks for any help with this.
Terry Riegel
More information about the Javascript
mailing list