...

View Full Version : JS Form Problem on a Mac



jhas50
09-07-2006, 04:40 AM
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:
<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:



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


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

_Aerospace_Eng_
09-07-2006, 06:01 AM
Names can't begin with a special character such as an underscore.

nw0rd
09-07-2006, 06:05 AM
_ <---

jhas50
09-07-2006, 06:07 AM
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

_Aerospace_Eng_
09-07-2006, 06:13 AM
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

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

jhas50
09-07-2006, 06:26 AM
Updated:

http://www.azschoolalliance.org/forms/survey/index_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.



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

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

_Aerospace_Eng_
09-07-2006, 06:32 AM
Your form doesn't seem to be working in Firefox for PC either. I get this on the next page.

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.

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

jhas50
09-08-2006, 03:52 AM
I was able to get this form to work in Firefox by one simple change:

I changed this line:

<input type="hidden" name="total">


To this:


<input id="total" type="hidden" name="total">

I also cleaned up the onsubmit handler.

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

Thanks,



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum