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 14 of 14
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable field via Drop Down Selection

    While I am here... I have one more inquiry.

    http://www.hcedesigns.com/spec.html

    Spa Shape Option in the form.
    To be exact its: "If yes, what shape would you prefer?"

    There are several options in the drop down for selecting a spa shape. Below it are the dimensions for the spa shape. The only two that can have the diameter option enabled are "half-circle" & "circle".

    I have the diameter field disabled by default. How do i specify enable when one of the two aforementioned spa shapes is chosen?

    Thanks!

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:

    Code:
    <select name="shape" class="txtFields" id="shape" 
    onchange="if(this.value.match(/Circle$/gi))
    {this.form.spadiameter.disabled=0}else
    {this.form.spadiameter.disabled=1}">
    .....Willy

  • #3
    New Coder
    Join Date
    Nov 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    He Willy...

    I am a bit a of a newb with this stuff.. could you show me where in my code that goes? Or just paste the code above and below yours?

    THanks,

  • #4
    New Coder
    Join Date
    Nov 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually!

    It works! I just copied the onchange portion of it and inserted into the select string. Works like a charm! Thank you very much!

    So that I learn, could you please translate this portion to english?

    if(this.value.match(/Circle$/gi)

    Thanks,

    -F

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It merely checks if the end of the selected option value matches the word circle... It does not mater if it is: circle, half-circle, semi circle or decircle (case insensitive)....

    .....Willy

  • #6
    New Coder
    Join Date
    Nov 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Great

    Well come to find out, not only should it enable it upon selection, but it should also disable the width & length fields simultaneously.

    Going to do some research first before I wave my white flag.

    See yeah and thanks for the help!

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hint: 0 is false; 1 is true...

  • #8
    New Coder
    Join Date
    Nov 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <select name="shape" class="txtFields" id="shape" onchange="if(this.value.match(/Circle$/gi))
    {this.form.spadiameter.disabled=0}else{this.form.spadiameter.disabled=1}">

    Ok above is the string you gave me, but i cant find anything that allows me to target multiple field elements on the same string.

    I tried using:

    <select name="shape" class="txtFields" id="shape" onchange="if(this.value.match(/Circle$/gi))
    {this.form.spadiameter.disabled=0}else{this.form.spadiameter.disabled=1}and{this.form.spawidth.disab led=0">

    But that didnt work, and i also didnt know how to add the final piece to also disable the spalength.

    Help!

  • #9
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There's several ways to do this...
    Here is one way which assigns the disabled value of one input to the disabled value of another which is ultimately assigned a value of true or false...

    Code:
    <select name="shape" class="txtFields" id="shape" 
    onchange="if(this.value.match(/Circle$/gi))
    {this.form.spadiameter.disabled=this.form.spawidth.disabled=this.form.spalength.disabled=0}else
    {this.form.spadiameter.disabled=this.form.spawidth.disabled=this.form.spalength.disabled=1}">
    .....Willy
    Last edited by Willy Duitt; 11-09-2004 at 08:18 PM.

  • #10
    New Coder
    Join Date
    Nov 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Im following you with this... i think :P

    Can i add more arguments by simply adding "=" in the statement?

    Example below:

    <select name="shape" class="txtFields" id="shape"
    onchange="if(this.value.match(/Circle$/gi))
    {this.form.spadiameter.disabled=this.form.spalength.disabled=this.form.spawidth.disabled=0}else
    {this.form.spadiameter.disabled=this.form.spalength.disabled=this.form.spawidth.disabled=1}
    ">

  • #11
    New Coder
    Join Date
    Nov 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, that disables the length, width, and diameter... unless you are on circle.

    Follow?

  • #12
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no hablo....

    Oh, if you are wanting to disable other fields while enabling the spadiameter... just add another line to both the if and the else conditionals (between the curly braces { <--->}) and assign a value of 1 if spadiameter is 0 and 0 if spadiameter is 1....
    Last edited by Willy Duitt; 11-09-2004 at 08:24 PM.

  • #13
    New Coder
    Join Date
    Nov 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, i got this to work, but there is one problem:

    <select name="shape" class="txtFields" id="shape" onchange="if(this.value.match(/Circle$/gi))
    {this.form.spadiameter.disabled=0}else{this.form.spadiameter.disabled=1}
    if(this.value.match(/Circle$/gi)){this.form.spawidth.disabled=1}
    if(this.value.match(/Circle$/gi)){this.form.spalength.disabled=1}">

    When you "reselect" one of the previous options, it doesnt reenable the fields...? Any ideas?

  • #14
    New Coder
    Join Date
    Nov 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    duh.. forgot the }else{

    ...lol


  •  

    Posting Permissions

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