Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Jul 2011
    Posts
    177
    Plugin Contributions
    0

    Default COWOA question: Dim Form Elements if Checkbox = True

    I have the COWOA mod installed and it has the ability to copy address from billing fields if the checkbox is checked. It does it's function correctly but visually the user might assume this hasn't happened.

    How can I dim the shipping address when the user checks the box?
    I assume I would use Javascript but I don't know how to code in Javascript

    This is the kind of effect I'm looking for: Name:  copy.png
Views: 229
Size:  5.5 KB



    To see the exact form im referring to, please add this product to cart and just hit checkout...
    http://www.pazzle.co.uk/index.php?ma...&products_id=3

  2. #2
    Join Date
    Jul 2011
    Posts
    177
    Plugin Contributions
    0

    Default Re: Dim Form Elements if Checkbox = True

    Going to bed now, will hope for replies in the morning :)

  3. #3
    Join Date
    Jul 2011
    Posts
    177
    Plugin Contributions
    0

    Default Re: Dim Form Elements if Checkbox = True

    Are there any Javascript programmers that could lend some advice?

  4. #4
    Join Date
    Jul 2011
    Posts
    177
    Plugin Contributions
    0

    Default Re: Dim Form Elements if Checkbox = True

    Someone I know has kindly written up a script that does exactly what I need, even using my page source so it should work out the box.

    He sent me this link to show me it's working, and said to copy the JS from this. http://jsfiddle.net/CPjpt/2/

    I put the code into a file, and saved as jscript_formdim.js. I then put this file in /public_html/includes/modules/pages/no_account as no_account is the name of the page I need this script to work on.

    If you go to my checkout page, you can see that the the script has been loaded, however the form does not dim when checked.
    I did notice in my dev tools console this error: Uncaught SyntaxError: Unexpected token ?

    Can someone please tell me what the means, do I need to place the code in a specific location or on a specific page?

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Dim Form Elements if Checkbox = True

    I notice on the jsfiddle page that it says (on the left) that jQuery 1.8.2 is active. Do you have jQuery on your site? If not (and if the code actually uses jQuery), you need to load or reference it before the script runs.

  6. #6
    Join Date
    Jul 2011
    Posts
    177
    Plugin Contributions
    0

    Default Re: Dim Form Elements if Checkbox = True

    Thank you for replying, I have downloaded the jquery library, I renamed jquery-1.8.2.min.js. to jscript_jquery-1.8.2.min.js.
    I put this file in the /public_html/includes/modules/pages/no_account directory along with the jscript_formdim.js.

    I thought for sure that would do it, unfortunately no change

  7. #7
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Dim Form Elements if Checkbox = True

    Scripts are called in alphabetical order, and jscript_formdim comes before jscript_jquery. Change the jquery name to jscript_1_jquery-1.8.2.min.js and see what happens.

  8. #8
    Join Date
    Jul 2011
    Posts
    177
    Plugin Contributions
    0

    Default Re: Dim Form Elements if Checkbox = True

    Okay I changed it, and source code says that the library is being loaded first. However, still not working and that error is still there.

    LOL im such a newbie, so sorry dude.

  9. #9
    Join Date
    Jul 2011
    Posts
    177
    Plugin Contributions
    0

    Default Re: Dim Form Elements if Checkbox = True

    He has informed me the following:

    the code needs to be either in $(document).ready() or after the HTML for your forms on the page
    What does he mean $(document).ready() ?
    I can't find the file that contains the form either, even developer toolkit doesn't find terms for the form.

  10. #10
    Join Date
    Jul 2011
    Posts
    177
    Plugin Contributions
    0

    Default Re: Dim Form Elements if Checkbox = True

    I read up about $(document).ready() and my understanding is that if forces the script to load before anything else on the page. So here's what I have...

    Code:
    <script type="text/javascript">
        $(document).ready(function () {
    if($("#shippingAddress-checkbox").attr("checked") == "checked")
    {
        $("#shippingField input:not(#shippingAddress-checkbox), #shippingField select:not(#shippingAddress-checkbox)").attr("disabled", "disabled");
    }
    else
    {
        $("#shippingField input:not(#shippingAddress-checkbox), #shippingField select:not(#shippingAddress-checkbox)").removeAttr("disabled");               
    }
    
    $("#shippingAddress-checkbox").click(function(){
       if($(this).attr("checked") == "checked")
       {
           $("#shippingField input:not(#shippingAddress-checkbox), #shippingField select:not(#shippingAddress-checkbox)").attr("disabled", "disabled");
       }
       else
       {
           $("#shippingField input:not(#shippingAddress-checkbox), #shippingField select:not(#shippingAddress-checkbox)").removeAttr("disabled");               
       }
    });?
    </script>
    I put it on tpl_modules_no_account.php. Nothing, nothing nothing. I have spent an entire day pasting this code in every possible variation in every possible file in every possible position.

    Can someone save the remainder of hair I have left?

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Odd extra elements in URL after form submission
    By gjh42 in forum Contribution-Writing Guidelines
    Replies: 5
    Last Post: 28 Aug 2014, 04:40 PM
  2. Replies: 10
    Last Post: 12 Nov 2009, 07:07 PM
  3. Gigantic button imgs and form elements!
    By theapeman in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 2 Jun 2007, 08:16 PM

Posting Permissions

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