Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Field tabulation


  • Please log in to reply

#1
ScHwErV

ScHwErV

    Member 5k

  • Retired Staff
  • 21,285 posts
  • MVP
I have started playing with a website and I had a request for something that I don't know how to do. I have seen it done before, but don't know if it can be done without the help of a script. Here is the basic idea.

Field 1 = Quantity
Field 2 = Price
Field 3 = Total of Field 1 * Field 2

Then, upon submission, I need to stick all 3 fields (among others) into an sql database.

Ideas?
  • 0

Advertisements


#2
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
I am sorry ScHwErV but I think your going to need a script for this. HTML dose not do math :whistling: The under development Xforms is going to from what I have read http://www.w3.org/MarkUp/Forms/ But it is not supported yet by any web browser.

As a security thing, make sure you use PHP to times Field 1 by Field 2 what ever else you do. If someone tampers with the page, Field 3 just might now have the value you expected.

Edited by Michael, 26 January 2007 - 04:47 PM.

  • 0

#3
ScHwErV

ScHwErV

    Member 5k

  • Topic Starter
  • Retired Staff
  • 21,285 posts
  • MVP
Having PHP do it and then submit the answer to SQL might be a better idea. In reality, the customer doesn't need to see the answer, but it would be nice if the answer were displayed on the output from SQL. So, is there a way to shoot the form through a PHP script that would submit a 3rd field?
  • 0

#4
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
What I would do is this.

I make the total box hidden using css. Then when the page loaded use JavaScript to unhide it. This means that people that don't use JavaScript can't see it, since they can't use it. Every one else can. Use JavaScript to times the other two fields together and display the result in the box.

At the same time, add a hidden field into the form. Call this "approved" and give it a value of false. But use JavaScript to change it to true. Now you know the person could not see the total field. If they could see the total field because they have JavaScript add all the data to the mysql data base along with a field called approve with a value of TRUE. If JavaScript was disabled still add the data to mysql but put the approve field to a value of FALSE. And give them a page to view that has all the information on it, including the value of field 1 times field 2. Once they have seen they they can press some button that then caused the php script to change the value of the approve field to true.

It should not be too hard to do, I can help you with it if you need it.

The result is those with JavaScript can do it faster, but those with out it can still do it. An important fact.

Michael
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP