Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-06-2012, 07:28 PM   PM User | #1
Razzy
New Coder

 
Join Date: Jun 2012
Posts: 41
Thanks: 14
Thanked 1 Time in 1 Post
Razzy is an unknown quantity at this point
disable the "SUBMIT" button until a couple of buttons are pressed first

hey people, i have a small problem for an order form. I have several sections within an order form. each section contains various products which have a value to it. A customer, when placing order will select products within a section or in different sections. each section will have a "total" button within. when clicked on, it will show the sub total of products within that particular section.

At the end of the form there is a button for the grand total, which will show the total cost of products from various sections that were selected.

what i want is the submit button to be disabled until.......

1) one or more (14 subtotal buttons) are clicked, so that the customer can view the subtotal

2)the grand total button is clicked so that the customer knows the total cost of the order.


would really appreciate it if someone could help

thank you
Razzy is offline   Reply With Quote
Old 08-06-2012, 07:44 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,585
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Almost none of this functionality can be done with HTML, let alone CSS. I suppose your application is done with PHP? So I’m gonna move this to the PHP forum. This can also be done with JavaScript but JS shouldn’t be the primary solution, it’s just for enhancement. Therefore the first stop is the PHP forum.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 08-06-2012, 08:30 PM   PM User | #3
Razzy
New Coder

 
Join Date: Jun 2012
Posts: 41
Thanks: 14
Thanked 1 Time in 1 Post
Razzy is an unknown quantity at this point
sorry VIPStephan, thank you for that
Razzy is offline   Reply With Quote
Old 08-06-2012, 10:57 PM   PM User | #4
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
If you want it to be done before submission (eg, page doesn't have to reload), then it has to be done with Javascript. As PHP is server side, you'd have to submit the form and then process it to figure out if the appropriate stuff is enacted without Javascript.
Keleth is offline   Reply With Quote
Old 08-06-2012, 11:43 PM   PM User | #5
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,585
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Yeah, that’s the point I was making. PHP functionality has to come first before any JS enhancements are done. One shouldn’t rely on JS alone.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 08-07-2012, 04:35 AM   PM User | #6
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,146
Thanks: 10
Thanked 148 Times in 148 Posts
DrDOS is infamous around these parts
Why not have javscript do it up right, write a javascript function that gets all the input values for the form, produces a modal window that shows all the subtotals and total, and has two buttons on it, one for NO and one for YES, if the totals are right, and the one for YES also enables the submit button. You can give a class to the form inputs if javascript has a problem with the form names.
DrDOS is offline   Reply With Quote
Old 08-07-2012, 02:51 PM   PM User | #7
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
I have to say though, I don't quite believe that PHP has to come first. Specially these days, I feel a Javascript solution as the primary is perfectly acceptable, AS LONG AS you have redundancies built into PHP to avoid breaking your system.

Now, I don't think that should always be true. If you don't NEED javascript to do whatever you want, then build the PHP first and use the JS to make it pretty. But if what you want to do cannot be achieved with PHP alone, I think using JS as the primary solution, and PHP as the backup is fine, given you'd end up limiting yourself a lot with PHP as the primary.

For example, I have a website on which players can build a grid map. I could have written A LOT of PHP to make a grid map work without JS, and then written the same amount of JS to do it. And in the end, people using it with the PHP would have just gotten frustrated, it'd be a lot more bug prone, etc. Instead, when JS isn't active, my system tells them the site won't function without it.

In this case, I think building a JS solution with a PHP redundancy is the right choice, specially as neither will be complicated. I don't think we should stay locked in to the idea that the site should ALWAYS work without JS and should just be prettier with it.
Keleth is offline   Reply With Quote
Old 08-07-2012, 05:12 PM   PM User | #8
Razzy
New Coder

 
Join Date: Jun 2012
Posts: 41
Thanks: 14
Thanked 1 Time in 1 Post
Razzy is an unknown quantity at this point
yes keleth i want it to be done before submission, i personally dont think its anything to do with php becos all i want is the submit button to be disabled until other buttons are clicked? but i may be wrong
Razzy is offline   Reply With Quote
Old 08-07-2012, 05:54 PM   PM User | #9
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
The basic code for enable/disable is:

Code:
<form action="" method="post">
<input name="rad" type="radio" value="Yes" onclick="this.form['sub'].disabled=false"> YES
<br>
<input name="rad" type="radio" value="No" onclick="this.form['sub'].disabled=true"> NO
<br>
<br>
<input type="submit" name="sub" value="Submit" disabled>
</form>
This is for radio buttons but the same code can be used for buttons.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 08-08-2012, 10:13 AM   PM User | #10
Razzy
New Coder

 
Join Date: Jun 2012
Posts: 41
Thanks: 14
Thanked 1 Time in 1 Post
Razzy is an unknown quantity at this point
thnx andrew, theres several buttons on this button, is there any way of linking these buttons to the submit button, so that a customer has to click on one or buttons before clicking the submit button

thanks
Razzy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 11:04 AM.


Advertisement
Log in to turn off these ads.