Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select and Option Tag Help Needed

    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....

    Code:
    <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
    Last edited by ApocalypticDon; 07-08-2012 at 09:47 AM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,423 Times in 4,388 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,980
    Thanks
    56
    Thanked 557 Times in 554 Posts
    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:
    Code:
    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:

    Code:
    <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>

  • #4
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xelawho View Post
    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:
    Code:
    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:

    Code:
    <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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •