I have a problem with the DIV tag (which I think is related with the Javascript). I need help because I cannot insert the form data into the database.
I really need help!!!! Thank you in advance
In the HTML part of my form, I have:Code:<script type="text/javascript"> var member_prices = new Array(); member_prices["no"]=200.00; member_prices["discount"]=75.00; member_prices["yes"]=100.00; // getMemberPrice() finds the price based on the membership type // Here, we need to take user's the selection from radio button selection function getMemberPrice() { var MemberPrice=0; //Get a reference to the form id="signup" var theForm = document.forms["signup"]; //Get a reference to the type the user Chooses name=member": var member = theForm.elements["member"]; //Here since there are 3 radio buttons member.length = 3 //We loop through each radio buttons for(var i = 0; i < member.length; i++) { //if the radio button is checked if(member[i].checked) { //we set MemberPrice to the value of the selected radio button //by using the member_prices array //We get the selected Items value //For example member_prices["no".value]" MemberPrice = member_prices[member[i].value]; //If we get a match then we break out of this loop //No reason to continue if we get a match break; } } return MemberPrice; } var lunch_prices= new Array(); lunch_prices["0"]=0; lunch_prices["yes"]=69.99; lunch_prices["no"]=0; //This function finds the Lunch prices based on the //drop down selection function getLunchPrice() { var LunchPrice=0; //Get a reference to the form id="signup" var theForm = document.forms["signup"]; //Get a reference to the select id="lunch" var selectedLunch = theForm.elements["lunch"]; //set Lunch Price equal to value user chose //For example lunch_prices[yes".value] would be equal to 69.99 ConfdinnerPrice = lunch_prices[selectedLunch.value]; //finally we return LunchPrice return LunchPrice; } function calculateTotal() { //Here we get the total price by calling our function //Each function returns a number so by calling them we add the values they return together var SignupPrice = getMemberPrice() + getLunchPrice (); //display the result var divobj = document.getElementById('total_payable'); divobj.style.display='block'; divobj.innerHTML = "Total Signup Fee £" + SignupPrice; } function hideTotal() { var divobj = document.getElementById('total_payable'); divobj.style.display='none'; }</script>
Code:<style type="text/css"> /*------------------Pay_total----------------*/ #wrap div#pay_total { padding:10px; font-size:14px; font-weight:bold; color:#dde9f2; background-color:#3b7eb0; } </style> <form name="signup" id="signup" action="confirm.php" onsubmit="return validateForm(this);"> Membership: <input type="radio" name="member" value="no" onclick="calculateTotal()" /> No <input type="radio" name="discount" value="discount" onclick="calculateTotal()" /> Student <input type="radio" name="member" value="yes" onclick="calculateTotal()" /> Yes <br /><br /> <br /><br /><label><strong>Register for Lunch?</strong></label> <select id="lunch" name="lunch" onchange="calculateTotal()"> <option value = "0" selected="selected">Please choose</option> <option value="yes">Yes</option> <option value="no">No</option> <p><div id="total_payable" name="total_payable"></div>




Reply With Quote

Bookmarks