View Full Version : DIV Tag & Javascript Dilemma for Database

04-28-2011, 10:39 PM
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 :)

<script type="text/javascript">
var member_prices = new Array();

// 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
//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
return MemberPrice;

var lunch_prices= new Array();

//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.innerHTML = "Total Signup Fee " + SignupPrice;


function hideTotal()
var divobj = document.getElementById('total_payable');

In the HTML part of my form, I have:

<style type="text/css">
#wrap div#pay_total


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

04-29-2011, 10:34 PM
where is your validateForm() function?

what makes you think this is a problem with the <div> tag (I'm not sure how it could be)?

why can you not submit to the database? is your form submitting correctly? is your server-side script processing the submission correctly?

04-30-2011, 02:47 AM
Actually I figured its not the <div> problem... its not an actual input element thus thats why it wasnt inserting into the database. My validateForm function is toooo long to be posting it here so I didn't ;)

I also realised I had some errors when writing the PHP code for inserting into the Database.

All has been resolved though :)

04-30-2011, 07:12 AM
glad to hear it