Forums

many forms in one article

daffy 10 Jun, 2009
I am putting together a web-site of many items for hire.
The dates and times and emails etc I have dealt with by a chronoform.
But now I have a catalogue with text and pictures and I want to put a button by each item saying 'Hire Me'. As a novice the solution that occurred to me was to put a small form with a hidden input with the stock-number of the item by each item with the submit button saying 'Hire Me', and deal with it with a PHP script. I want ten of these per page and about 30 such pages=300 'small forms'.

(Is there a better way of doing this?)

When I put ten forms differing only in their hidden input value but all having the same ID then (of course) it doesn't work.

question 1.
Does it make any sense to use a tiny chronoform for this or is it 'overkill'. Chronoforms provides a 'copy' facility.

I tried putting ten little simple HTML forms then using Javascript with the DOM to change all their IDs to sequential values 'form_1' 'form_2' etc. But this was no better.

As a novice when something does not work I don't know if it is wrong in principle or whether there is a typo or something (such as 'domready') is missing.
Question 2
What differences should I make between one form and the next for them to work in the same article ?

I tried making the whole page as one form and just having ten different submit buttons ! but I have not workout how to handle that in a PHP script!.


Any advice or help is welcome.
--
Dave
GreyHead 10 Jun, 2009
Hi Dave,

As an aside - this looks like a ChronoConnectivity project.

I'd probably do this by using one ChronoForm and wrapping a link around a button image by each item with
<a href='index.php?option=com_chronocontact&chronformname=buy_me&item_id=9999'><img . . .></a>
Then in the Chronoform check for the item_id in the Get variables
$item_id = JRequest::getInt('item_id', '', 'get);
You can then use $item_id to get the relevant data from the table and build the buy-me for for that item.

Bob
daffy 10 Jun, 2009
Thanks Bob, A excellent and helpful reply as usual!
I have not investigated chronoconnectivity yet...it is such a long name!

I understand the idea which is to make a link to a single chronoform with suitable image buttons.
The pass the item id as part of that link...I am not very good with links yet.
Then some PHP in the single chronoform can use JRequest to get the ID and that same piece of PHP can look up full data about the particular item and put it somewhere ? Where ?

Into the database table for the particular customer to be analysed at checkout ?

How do I get it from the PHP into the chronoform's normal data. This connection between the 'outside world' and the chronoforms elements still eludes me.

But thanks very much I will do some more work.
I suppose I could try using DOM and scripting to write all the links for the buttons.
--
Dave
GreyHead 10 Jun, 2009
Hi Dave,

More info needed. What do you want the 'buy me' mini-form to do?

Bob
daffy 10 Jun, 2009
Thanks Bob, yes I suppose that is a good question !
Having got the item 'selected' it needs to be either saved in a table withother selected items accompanied by the customers details OR saved as a 'session' variable along with other items.
Until checkout this is a very temporary selection.

By the way having downloaded and installed the latest rc5.1 I now get an error message when I try to save a newly created chronoform. the message is long but starts as
TableChronoContact::store failed - Unknown column 'stylecode' in 'field list' SQL=UPDATE `jos_chrono_contact` SET `name`='mainform',`html`='

Seems the database need modifying ??
--
dave
GreyHead 10 Jun, 2009
Hi Dave,

There's an 'Upgrade MySQL' link in the Forms Manager that will add the stylecode field to the tables (and a few other upgrades too).

To store the item temproarily probably the simplest thing is to use a javscript snippet to put the id into a cookie.*

Bob

* MooTools has a Hash.Cookie() function that will let you build an array in a cookie.
daffy 10 Jun, 2009
Thanks Bob,
The database errors cleared now.
--
dave
daffy 12 Jun, 2009
Bob
Your solution worked fine BUT I had forgotten that some of my items have options eg 'red' or 'green' or 'blue' that was one reason why I looked towards a tiny form as the solution. Unless of course you can offer a better one !! A select or a Radio Button will not work other than on a form will it??
Any thoughts ?
--
dave
GreyHead 12 Jun, 2009
HI Dave,

How are you showing the options? Could still be done with links &product_id=123&option=xyz

Bob
daffy 12 Jun, 2009
Bob thanks for your thoughts,
The obvious way is to have a select drop-down and the client clicks it show his selection then he clicks on the main 'hire this' button.
But I could have say 3 little buttons and select 'red-hat' 'green-hat' or 'blue-hat' each with a different code.

Actually what I had in mind was a code of 14-02-03 where 14 was the article number, 02 was the second item shown in the article and 03 was option no 3 of that item.
The actual item being shown on article 14, item 2, option 3 would be stored/looked-up in the database.
I could have 3 radio buttons instead of a drop-down but how can I assemble the code I want without using a 'form'.

T suppose I could have radio-button on_click...assemble one bit of code then 'hire_me' add the rest and do the link but my mind boggles a bit about javascript to do this. Do you get 'on_click' with a radio button ???
--
Dave
GreyHead 14 Jun, 2009
Hi Dave,

You could go the radio button route - the onChange event is available. You could have three little colour swatches each labelled 'buy me!'.

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