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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onClick problem with IE

    Hi,

    I have a very simple problem, i'm doing a form of which i want some fields to be enabled/diabled based on selection. Got it working fantastic in FF but not IE.

    I wonder if anyone can help

    Heres the examples (i've cut out the irelevant HTML) :

    Code:
     function drinksonlyon()
     {
     	  document.forma.fldHead.disabled=true; 
    	  document.forma.fldVegan.disabled=true;
    	  document.forma.fldGluten.disabled=true;
      }
    
    <OPTION VALUE='999' onclick="drinksonlyon (); "/>Blah </OPTION>
    
    <input type="text" name="fldHead" id="fldHead"  tabindex="15" size='5' />
    OR

    Code:
    <input type=radio name="fldblah" id="fldblah"   onclick="javascript:document.forma.fldblah.disabled=false"/> No<br />
    
    <textarea name="fldInvoice" id="fldblah"  tabindex="9" cols=30 rows=5  disabled></textarea>
    If anyone can point me in the right direction i'd be very happy.

    Thanks

    Gary

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    1. Use onchange event aplied on SELECT control

    <select onchange="this.value=='999'?drinksonlyon ():null">
    ...
    <option value='999'>Blah </option>

    IE does not support onclick upon option object.

    2. To enable a disabled element, rather use DOM:

    object.removeAttribute('disabled')
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok how does it work with multiple and differing selections? Maybe I should of posted the full thing first You can see what i'm wanting to do as different choices need different fields.

    Code:
    <div>
    <label for="fldBuffet">Buffet:</label>
    <select name="fldBuffet" id="sBuffet"  tabindex="14">
    <option >SELECT</option>
    <OPTION VALUE='5' onclick="drinksonlyoff ();">Business Buffet</OPTION>
    <OPTION VALUE='31' onclick="teacoffee(); ">Tea &amp; Coffee with biscuits </OPTION>
    <OPTION VALUE='37' onclick="drinksonlyoff ();">Members Tea Menu 4</OPTION>
    <OPTION VALUE='999' onclick="drinksonlyon (); ">Drinks Only - see below</OPTION>
    </select>
    </div>
    I've never really dabbled with java of any sort before, other than ready made scripts.

    Thanks

    Gary

  • #4
    New to the CF scene
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    2. To enable a disabled element, rather use DOM:

    object.removeAttribute('disabled')

    Sorry this doesn't mean anything to me - i know what i know and there's where it stops! could you show me how it would look in the radio button and the text area what it enables?

    Thanks (Multum esc)

    Gary

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Here'a simple example how setAttribute() and removeAttribute() work:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    function enableField(f,v){
    v.length<1?f['bttnsubmit'].setAttribute('disabled',true):f['bttnsubmit'].removeAttribute('disabled')
    }
    </script>
    </head>
    <body>
    <form>
    <textarea onkeyup="enableField(this.form,this.value)"></textarea>
    <br>
    <input type="submit" value="Submit" name="">
    </form>
    </body>
    </html>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    New to the CF scene
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're obviously far more clever than I because that makes absolutley no sense Remember I know absolutely nothing about this stuff, I was amazed when what i did worked in firefox!

    Maybe you know a good site where I can start from scratch. DOM for Dummies .com or something?

    If anyone can layout what is neeed using the fld names and ID's that i've been using in my code than it would make more sense becasue i could follow it.

    I dont even know which parts I am to put my own stuff in or keep it as is?

    Many thanks

    Gary

  • #7
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Some of the online tutorials for javascript/DOM are really good:

    http://www.w3schools.com/js/default.asp
    http://www.howtocreate.co.uk/tutoria...t/introduction
    http://www.quirksmode.org/

    The standard javascript and DOM are:

    EcmaScript
    http://www.ecma-international.org/pu...s/Ecma-327.htm
    w3c DOM
    http://www.w3.org/TR/DOM-Level-2-Core/core.html

    Unfortunately javascript/DOM, even now is a stabile language, is not full standardized, usually browsers have some particular methods/behaviours. Good tutorials show the most important differences (mainly between IE and Moz)
    Edit/Delete Message
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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