Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #14300
| From | Scott Johnson <noonehome@chalupasworld.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Changing styles values by Element Name |
| Date | 2012-06-03 06:46 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <jqfps1$r9j$1@dont-email.me> (permalink) |
Is it possible to change a batch of elements style values by using those
elements name.
Here is my situation.
I have several colors swatch images (sample)
<img id='color1::mens::size40' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color2::mens::size40' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color3::mens::size40' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color4::mens::size40' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color1::mens::size42' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color2::mens::size42' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color3::mens::size42' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color4::mens::size42' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color1::womens::size40' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color2::womens::size40' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color3::womens::size40' name='color_swatch' src='...'
onclick='select(this)'/>
<img id='color4::womens::size40' name='color_swatch' src='...'
onclick='select(this)'/>
What I would like to do is when one is clicked on it will place a border
on it.
This I have been able to do:
function select(oElement) {
oElement.style.border = "3px solid red";
}
However the issue I run into is clearing the border when another one is
selected.
Since all the ids have numerous values I tried to use a common name and
then clear all the borders before setting one.
function select(oElement) {
document.getElementsByName('color_swatch').style.border = "1px solid
gray";
oElement.style.border = "3px solid red";
}
This is barfing on setting the 'name' style.
Maybe I am coming at this in the wrong direction, I am conceding to the
knowledge of those who have been doing this for awhile.
Thanks
Scotty
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-03 06:46 -0700
Re: Changing styles values by Element Name Martin Honnen <mahotrash@yahoo.de> - 2012-06-03 15:53 +0200
Re: Changing styles values by Element Name "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-06-03 15:44 +0000
Re: Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-03 09:06 -0700
Re: Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-03 09:22 -0700
Re: Changing styles values by Element Name Jeremy J Starcher <r3jjs@yahoo.com> - 2012-06-05 20:26 +0000
Re: Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-05 20:52 -0700
Re: Changing styles values by Element Name "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-06 09:57 +0000
Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-09 11:43 +0200
Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-09 13:03 +0200
Re: Changing styles values by Element Name "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-09 14:14 +0000
Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-09 18:13 +0200
Re: Changing styles values by Element Name Luuk <luuk@invalid.lan> - 2012-06-09 18:35 +0200
Re: Changing styles values by Element Name "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-10 10:33 +0000
Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-10 14:50 +0200
Re: Changing styles values by Element Name SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-06-04 15:32 +0200
csiph-web