...

View Full Version : Select and Option Tag Help Needed



ApocalypticDon
07-07-2012, 01:32 AM
Ok so im workin on a project for work and its been a little while since I was in school for this. Currently my code looks like this....


<select size="4" name="tango" multiple="yes" onchange="window(this[selectedIndex].text)">
<option value="MQCC">MQCC</option>
<option value="KAT9">KAT9</option>
<option value="KBL0">KBL0</option>
<option value="K0VY">K0VY</option>
<option value="MQCC">MQCC</option>
<option value="KAT9">KAT9</option>
<option value="KBL0">KBL0</option>
<option value="K0VY">K0VY</option>
</select>

now that is a small version of how many i have to do but i want when the user clicks on one of these, it opens a diagram for those(these are curcuits so it would open the curcuit card) tried google and W3C or whatever that site is but no one seems to have made tutorial for this. I want the diagram it opens to be displayed right beside it on same page. If anyone has info on this i would like the help

Old Pedant
07-07-2012, 06:37 AM
Are the diagrams images? Or do you mean you will create a canvas object and then draw lines, etc., on it?

Clue for you: When the value= and the text of an <option> are the same, you can omit the value=. Just means a minor adjustment in JS coding.

xelawho
07-07-2012, 12:49 PM
it's hard to say without seeing your actual function, or, as Old Pedant says, knowing what the things you are trying to show actually are.

a couple of things, though: it seems to me that your function name is "window" which is asking for trouble - there is a native window object in javascript, called window - you might be able to get away with this, but in the interests of avoiding conflicts it's better to keep names unique. the convention for naming functions is camel script, so I guess something like showWindow

the other side of what Old Pedant says is that if the value and the text are the same you can access the value onchange using this.value, like so:

onchange="showWindow(this.value)"

the advantage of this being that the option text (what the user sees) and value (what gets passed to the funtion) can be completely independent:


<select size="4" name="tango" multiple="yes" onchange="showWindow(this.value)">
<option value="MQCC">Bee</a></option> <!-- btw, what's the </a> tag doing here? -->
<option value="KAT9">Bop</option>
<option value="KBL0">A</option>
<option value="K0VY">Loo Bop</option>
<option value="MQCC">A Wop</option>
<option value="KAT9">Bam</option>
<option value="KBL0">Boom</option>
<option value="K0VY">Tutti Frutti</option>
</select>

ApocalypticDon
07-08-2012, 09:47 AM
it's hard to say without seeing your actual function, or, as Old Pedant says, knowing what the things you are trying to show actually are.

a couple of things, though: it seems to me that your function name is "window" which is asking for trouble - there is a native window object in javascript, called window - you might be able to get away with this, but in the interests of avoiding conflicts it's better to keep names unique. the convention for naming functions is camel script, so I guess something like showWindow

the other side of what Old Pedant says is that if the value and the text are the same you can access the value onchange using this.value, like so:

onchange="showWindow(this.value)"

the advantage of this being that the option text (what the user sees) and value (what gets passed to the funtion) can be completely independent:


<select size="4" name="tango" multiple="yes" onchange="showWindow(this.value)">
<option value="MQCC">Bee</a></option> <!-- btw, what's the </a> tag doing here? -->
<option value="KAT9">Bop</option>
<option value="KBL0">A</option>
<option value="K0VY">Loo Bop</option>
<option value="MQCC">A Wop</option>
<option value="KAT9">Bam</option>
<option value="KBL0">Boom</option>
<option value="K0VY">Tutti Frutti</option>
</select>

Sorry </a> was there cause i was tryin to add some linked thing to it cause i i wasnt sure how to get it to work and yes these diagrams are images



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum