Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #18024
| Message-ID | <2021719.oBrLI1RlBM@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2013-01-09 00:36 +0100 |
| Subject | Re: Matching arbitrary pairs of elements |
| Newsgroups | comp.lang.javascript |
| References | <1kwe933.qjka3b5vluq5N%real-not-anti-spam-address@apple-juice.co.uk> |
| Followup-To | comp.lang.javascript |
Followups directed to: comp.lang.javascript
D.M. Procida wrote:
> So far I have managed to come up with http://jsfiddle.net/j2xYs/ - which
> works, for one pair of select/input elements.
This is not the Web. Surely you can also post a reduced test case here.
See <http://jibbering.com/faq/#posting> or
<http://PointedEars.de/faq#posting>.
> Now in my interface there will be an arbitrary number of these pairs,
> with matching numbered ids.
>
> What I'd like to do is amend my JS so that if <select id="[number]"> is
> changed to "show", then <input id="[number]"> will be shown, whatever
> [number] is.
Only if you declare and use HTML5, IDs are allowed to start with “[”.
Otherwise they MUST NOT contain the “[” or “]” characters, and MUST NOT
start with a decimal digit either.
<http://www.w3.org/TR/1999/REC-html401-19991224/types.html#h-6.2>
<http://www.w3.org/TR/2012/CR-html5-20121217/dom.html#the-id-attribute>
If you are not declaring and using HTML5, you could use the “name”
attribute, though, which is backwards-compatible and allows both “[” and
“]”, because it is of type CDATA. (The “name” attribute is allowed for
“form” elements and form controls in HTML5 as well. However, for form
controls HTML5 attaches special meaning to it.)
<http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-
name-INPUT>
<http://www.w3.org/TR/2012/CR-html5-20121217/forms.html#attr-fe-name>
> I'm sure this must be possible, but this is the first time I've tried to
> do something in JS so I am not really sure where to start.
You could start like this:
<select id="select1"
onchange="console.log([this.id,
this.options[this.selectedIndex].value].join('\n'))">
<option value="hide">hide</option>
<option value="show">show</option>
</select>
(You should remove word-wrap in your code.)
However, if there are only two choices, it is probably better to use a
checkbox instead (and for three choices a radiobutton group, unless space is
limited). See <https://developer.mozilla.org/en/docs/DOM> for more.
> Thanks for any suggestions or advice,
You are welcome.
> Daniele
You should put that in the sender (“From” header field value), too.
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Matching arbitrary pairs of elements real-not-anti-spam-address@apple-juice.co.uk (D.M. Procida) - 2013-01-08 19:41 +0000
Re: Matching arbitrary pairs of elements Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-09 00:36 +0100
Re: Matching arbitrary pairs of elements real-not-anti-spam-address@apple-juice.co.uk (D.M. Procida) - 2013-01-09 11:46 +0000
Re: Matching arbitrary pairs of elements Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-09 18:24 +0100
Re: Matching arbitrary pairs of elements John G Harris <niam@jghnorth.org.invalid> - 2013-01-09 16:34 +0000
Re: Matching arbitrary pairs of elements "Leonardo Azpurua" <leonardo@exmvps.org> - 2013-01-08 23:11 -0430
Re: Matching arbitrary pairs of elements Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-16 12:49 +0100
Re: Matching arbitrary pairs of elements Tim Streater <timstreater@greenbee.net> - 2013-01-16 12:47 +0000
Re: Matching arbitrary pairs of elements Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-16 14:27 +0100
Re: Matching arbitrary pairs of elements Tim Streater <timstreater@greenbee.net> - 2013-01-16 13:52 +0000
Re: Matching arbitrary pairs of elements Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-16 18:48 +0100
Re: Matching arbitrary pairs of elements Tim Streater <timstreater@greenbee.net> - 2013-01-16 17:58 +0000
Re: Matching arbitrary pairs of elements John G Harris <niam@jghnorth.org.invalid> - 2013-01-17 14:30 +0000
Re: Matching arbitrary pairs of elements Jeff North <jnorthau@yahoo.com.au> - 2013-01-10 13:11 +1100
Re: Matching arbitrary pairs of elements real-not-anti-spam-address@apple-juice.co.uk (D.M. Procida) - 2013-01-11 10:32 +0000
Re: Matching arbitrary pairs of elements RobG <rgqld@iinet.net.au> - 2013-01-13 22:36 -0800
csiph-web