Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 11-20-2008, 01:05 PM   #1 (permalink)
Member
 
Join Date: 07-29-08
Location: Ohio
Posts: 60
iTrader: 0 / 0%
Latest Blog:
Red Eye

RNK Concepts is liked by many
Looking for an answer for best code.

Hello,

I have an online form that I am building in PHP. Basically, I need the user to fill out certain form fields, and when those fields are completed, I need to automatically post the data in those fields into fields within an equation that is visible on screen. The following picture shows the circled area and where it should appear in the equation.



I am currently trying to use $POST data ... But I'm thinking that ajax would work much better ... Any ideas?

Any links to the code that may help is greatly appreciated!

Thanks.
RNK Concepts is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-20-2008, 01:57 PM   #2 (permalink)
Contributing Member
 
Join Date: 11-17-08
Location: NJ
Posts: 55
iTrader: 0 / 0%
Latest Blog:
None

leonid is on the right pathleonid is on the right path
I don't quite understand the flow.

You have 6 input fields, but only 3 x'es

if x is a placeholder (in the equation) for the input field, then shouldn't you have 6 of them?
__________________
Leonid
leonid is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-20-2008, 02:18 PM   #3 (permalink)
Member
 
Join Date: 07-29-08
Location: Ohio
Posts: 60
iTrader: 0 / 0%
Latest Blog:
Red Eye

RNK Concepts is liked by many
Actually the "x" is suposed to represent a multiplication sign ... The area directly before the "x" should 'echo' the result of what the user types into the After Repair Value field ... I need this to happen instantly also ... As soon as the user clicks another field ... I want the submitted value to appear in the 'equation' and when they click calulate ... The result is shown after the Offer label.

Does that make sense?

Basically I want them to see how the equation works ...

Thanks
RNK Concepts is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-20-2008, 04:14 PM   #4 (permalink)
Contributing Member
 
Join Date: 11-17-08
Location: NJ
Posts: 55
iTrader: 0 / 0%
Latest Blog:
None

leonid is on the right pathleonid is on the right path
OK,

in that case you don't need Ajax (ajax goes to the webserver).
All you need is some javascript to manipulate the page directly in the browser.

something along these lines:

input type="text" onblur="document.getElementById('target1').innerHT ML = this.value"

div id="target1">
__________________
Leonid
leonid is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-20-2008, 04:18 PM   #5 (permalink)
Contributing Member
 
Join Date: 11-17-08
Location: NJ
Posts: 55
iTrader: 0 / 0%
Latest Blog:
None

leonid is on the right pathleonid is on the right path
Capo64:

How did you create those code sections?
__________________
Leonid
leonid is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-20-2008, 04:12 PM   #6 (permalink)
Contributing Member
 
Join Date: 06-11-07
Posts: 238
iTrader: 0 / 0%
Latest Blog:
None

Capo64 is a jewel in the roughCapo64 is a jewel in the roughCapo64 is a jewel in the roughCapo64 is a jewel in the roughCapo64 is a jewel in the roughCapo64 is a jewel in the rough
You need JavaScript for this (or atleast that's the most sensible solution).

set up your form like this:

Code:
<form> Value 1: <input onchange="calc();" type="text" name="value1" id="value1" /> Value 2: <input onchange="calc();" type="text" name="value2" id="value2" /> etc. </form> <div id="equation"></div><input type="button" value="Calculate" onclick="calc();" /> <div id="total"></div>
and the JavaScript would be:

Code:
<head> <script type="text/javascript"> calc() { document.getElementById('equation').innerHTML = document.getElementById('value1').text + ' x ' + document.getElementById('value2').text + ' - ' + document.getElementById('value3').text + ' = ' + (document.getElementById('value1').text * document.getElementById('value2').text - document.getElementById('value3').text); } </script> </head>
I hope that's enough for you to create your own version 'cause I don't feel like typing anymore lol
Capo64 is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-20-2008, 05:39 PM   #7 (permalink)
Contributing Member
 
Join Date: 06-11-07
Posts: 238
iTrader: 0 / 0%
Latest Blog:
None

Capo64 is a jewel in the roughCapo64 is a jewel in the roughCapo64 is a jewel in the roughCapo64 is a jewel in the roughCapo64 is a jewel in the roughCapo64 is a jewel in the rough
surround your text with [ CODE][ /CODE] (without spaces)


You seem to be trying to make this more complicated than it has to be. JavaScript is more than capable of performing simple math equations. If you wanted to log the values that people were putting in, or do something a little more advanced, you might want to use AJAX with PHP. Not for this though..
Capo64 is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-20-2008, 06:18 PM   #8 (permalink)
Contributing Member
 
Join Date: 11-17-08
Location: NJ
Posts: 55
iTrader: 0 / 0%
Latest Blog:
None

leonid is on the right pathleonid is on the right path
Capo64: great, thanks!!!

Code:
<input type="text" name="test">test test</input>
__________________
Leonid
leonid is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-21-2008, 08:18 AM   #9 (permalink)
Member
 
Join Date: 07-29-08
Location: Ohio
Posts: 60
iTrader: 0 / 0%
Latest Blog:
Red Eye

RNK Concepts is liked by many
Thanks

Capo:

Thanks for the info ... I think that what I explained seems a bit more complex than what it is supposed to be. I just need whatever the user types in the input field to immediately appear in the equation ... I agree that Javascript will work ... I just wanted to confirm that.

I figured php would not because of the server side processing.

Thanks for the advice ... Now I can start to put this thing together.
RNK Concepts is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Analytics old code vs new code m42 Google Forum 0 03-29-2008 01:04 AM
Pls answer for this ... Swapna SEO Forum 9 03-05-2008 06:48 AM
Nobody has answer Mong Google Forum 29 04-11-2007 06:09 PM
I need an answer.please!! admimsid SEO Forum 11 03-17-2007 01:28 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 08:18 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.