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

    Unhappy JS Form Problem on a Mac

    I have some Mac users telling me they cannot access a form I have built and I'm wondering if my JS is the cause of the problem.

    Not having access to a Mac makes it really hard for me to test, therefore I was hoping to get some feedback on what could be causing the problem from some helpful folks here.

    The live form is located here http://www.azschoolalliance.org/forms/survey/

    And the JS in question:
    Code:
     <script language="Javascript" type="text/javascript">
    
    function setRedirect(){
    var sum = document.survey.total.value 
    
       if(sum != "") {
       
       
       document.survey._browser_out.value = sum + '.shtml'
       
    
       }
       else{
       alert("Please select one or more roles!")
       }
    
    }
    </script>
    After the form I have the following script:

    Code:
    <script language="JavaScript" type="text/javascript">
    var total = document.getElementById("total")
    function clickCh(caller){
    if(caller.checked){
    add(caller)
    } else {
    subtract(caller)
    }
    }
    function add(caller){ total.value = total.value*1 + caller.value*1}
    function subtract(caller){ total.value = total.value*1 - caller.value*1}
    </script>
    The form has special survey questions for different user roles, and sometimes a user fills multiple roles and should see the corresponding questions for both roles.

    I have assigned values to the three check boxes of 1, 3, and 5 for the different roles, and then made pages named 1.shtml, 3.shtml, 4.shtml, 5.shtml, 6.shtml, 8.shtml, and 9.shtml with the different combinations of questions corresponding to the roles the user selects.

    The script then calculates the total value of the checked boxes and redirects the user to that page (1,3,5.shtml, etc.). I am using Form Processor Pro as the php form action, the redirect field 'browser_out' is a feature of this program and I have been able to get other forms to work on a Mac therefore I believe it is my JS that is causing the problem.

    I can't remember where I pulled the remnants of JS code that gave me this functionality, and I know it is probably a hack...but thats about my level of understanding of JS anyways.

    I'm not really looking at redoing this entire form the proper way, I'm just looking to get it to work the easiest way possible.

    Here is the simplified form HTML:

    Code:
    <form name="survey" method="POST" action="/cgi-bin/form_pro/formprocessorpro.php" enctype="multipart/form-data">
    <input type="hidden" name="base_path" value="/home/azschool/www/www/forms/survey/">
    
    <input type="hidden" name="total">
    
    <input type="hidden" name="_browser_out">
    
    <input onclick="clickCh(this)" type="checkbox" name="dist_contact" value="1"> District Contact
    
    <input onclick="clickCh(this)" type="checkbox" name="loss_contact" value="3"> Loss Control Contact
    
    <input onclick="clickCh(this)" type="checkbox" name="claim_contact" value="5">Claims Contact
    
      <input type="submit" value="Next" name="Next" onclick="setRedirect()" style="font-family: Verdana; font-size: 10pt; font-weight: bold">
    Thanks in advance for your help!

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Names can't begin with a special character such as an underscore.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    lol

    _ <---

  • #4
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have another form that uses the same "_browser_out" field and I am told it works fine on a Mac...

    http://www.gkemployees.net/jobs/app/eng/app_eng.php

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Either way it shouldn't be done but your problem might be your method of doing your calculations. I'll try to explain. You are trying to multiply a string by a number therefore it could be erroring out on a mac because its not the proper method. Try this
    Code:
    <script type="text/javascript">
    var total = document.getElementById("total")
    function clickCh(caller){
    if(caller.checked){
    add(caller)
    } else {
    subtract(caller)
    }
    }
    function add(caller){ total.value = Number(total.value) + Number(caller.value)}
    function subtract(caller){ total.value = Number(total.value) - Number(caller.value)}
    </script>
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Updated:

    http://www.azschoolalliance.org/form...ndex_new.shtml

    I didn't change the _browser_out field name as I don't know how I would get the second page of questions without using the form processors built in field name.

    Thanks for your help and patience.


    Quote Originally Posted by _Aerospace_Eng_ View Post
    Either way it shouldn't be done but your problem might be your method of doing your calculations. I'll try to explain. You are trying to multiply a string by a number therefore it could be erroring out on a mac because its not the proper method. Try this
    Code:
    <script type="text/javascript">
    var total = document.getElementById("total")
    function clickCh(caller){
    if(caller.checked){
    add(caller)
    } else {
    subtract(caller)
    }
    }
    function add(caller){ total.value = Number(total.value) + Number(caller.value)}
    function subtract(caller){ total.value = Number(total.value) - Number(caller.value)}
    </script>

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Your form doesn't seem to be working in Firefox for PC either. I get this on the next page.
    Quote Originally Posted by azschoolalliance
    Member Worksheet Error Message:
    File Access Error

    An error occurred when opening the Browser Template (/home/azschool/www/www/forms/survey//): $!.
    You may want to put some alerts in your scripts to alert their values.
    Code:
    <script language="Javascript" type="text/javascript">
    
    function setRedirect(){
    var sum = document.survey.total.value 
    
       if(sum != "") {
       
       
       document.survey._browser_out.value = sum + '.shtml'
       
    alert(document.survey._browser_out.value);
       }
       else{
       alert("Please select one or more roles!")
       }
    
    }
    </script>
    I'm getting the "Please select one or more roles!" alert even after I've selected a role.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Solved

    I was able to get this form to work in Firefox by one simple change:

    I changed this line:
    Code:
    <input type="hidden" name="total">

    To this:
    Code:
    <input id="total" type="hidden" name="total">
    I also cleaned up the onsubmit handler.

    I'm assuming this will work on a Mac...

    Thanks,


  •  

    Posting Permissions

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