Forums

Is it possible to achieve this please?

HSN 17 Nov, 2009
Hi All,

Been keeping busy doing a few things but im at the stage again where I am looking at doing some forms. Well I say forms, its a little different to that really.

http://www.greencleansolution.co.uk/?p=quotebook&s=quote&u=tenancy if you click on this link you will see a set of drop down boxes. Ultimately if you say select the first in each then click on the button you get the next page which ends up being a quote/estimation.

You then have the choice of booking the service with that estimation (or based on).

So my question is, is it possible to create the estimation/quotation form using drop down boxes and a button? Further more is it then possible to link the given estimate/quote to another form if they choose to book the service?

I have a very crude idea on how this may possibly work, but im no guru on php and databases so im a little stuck.

My theory is that if you have a set of tables in the data which holds (im going to use that website as an example) the number of rooms and a cost based on this (so as an example bedrooms could be say 1 bedroom = £10, 2 bedrooms = £20, 3 bedrooms = £30 or even slightly different, but ultimately each room has a cost associated with it). The drop down box would show the number of rooms but the cost would be hidden. Once all fields are selected and the button is pressed, the form would then calculate the total (or even carry the total cost from a hidden field) to the new page.

Im open to thoughts here, but this would be a very handy mechanism to be able to do with chronoforms, especially for the project im working on.

Regards,
Max_admin 17 Nov, 2009
Hi HSN,

You can have a form like this and use PHP code on submit to process the values submitted, make your calculations and show the total quote in the next page, you may then redirect the sure to any page you like, is this what you need to do ?

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
HSN 17 Nov, 2009
Hi Max,

Many thanks for your reply. In essence I wish to have some tables in the database with 2 columns. 1 for a number to signify the number of rooms and the other for a price.
Each drop down is subject to a different table containing the same format.

The user makes their selections, with the last drop down box asking the room sizes (small, med or large).
When the user clicks the submit button I would look for the costs on each drop down being added together and then being multiplied by the value of the last drop down (small = 1x, med = 1.5 x or ,arge = 2 x as an example)

This data is then passed over to the results page showing what the user chose and the estimated cost.

It would be nice if there was a button there also which allowed the user to book this estimated cost as a job in which case they would be taken to a page asking for all the usual details (name, address etc). To get this mutlipage thing sound easy enough by using the already existing mutlipage feature. Its just the data from the database and calculations im hung on etc. and how to pass this tot he next page.

Regards,
Max_admin 18 Nov, 2009
Hi HSN,

you need to use some SELECT statements to load the result from every table row using the supplied posted value and then do the calculations, you can find lots of examples about SELECT statements here on the forums, I will give you a short example and hopefully you can continue:


all code will be in the onsubmit after email box

<?php
$query     = "SELECT `target_field_name` FROM `#__table_name_here` WHERE `field_name` = '".$_POST['form_field_name']."'";
$database->setQuery( $query );
$result_1 = $database->loadResult();
?>


after that you should have some variables like $result_1 and _2...etc to sum/multiply to get the total!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
HSN 18 Nov, 2009
Hi Max,

Once again many thanks for your reply. I think I am getting severly muddled now (sorry not a php person).

The example code you gave (obviously alter the table and field names to suit) would go in the onSubmit area of chronoforms ? Along with the code to calculate the sums?

Q1. How does the code know what options are available to display to the user completing the form?
Q2. Would you be able to assist me ? Again I am no php person and would struggle to get anywhere truth be told.

Many thanks,

Tom.
HSN 18 Nov, 2009
Hi Max,

I have been looking around and trying to understand both what the select statements do and what you meant in terms of using them. Unfortunately I failed miserably on both counts and am no nearer to understanding or achieving the desired result.

I would be ever so grateful if this would be something you could assist me on, and no doubt others too would benefit from this outcome as I think there are a couple of others wanting something similar to this (from what google searches have brought up in its results).

Regards,

Tom.
HSN 19 Nov, 2009

all code will be in the onsubmit after email box



Just spotted this bit sorry Max. onsubmit after email... so is this only due to be executed after the email has been sent ?
forwarddesign 24 Nov, 2009
I´m so curios, did you ever come to a solution in this matter and in that case hao did you do it?
I really would like to find a solution to this problem!
Tanks!
GreyHead 24 Nov, 2009
Hi Tom,

The code could also go in the OnSubmit Before box - that would make more sense here. You are going to need a little PHP & MySQL to make this work.

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger