Forums

[SOLVED] HTML Submit button to carry data into CF Form

akerman 16 Nov, 2010
Hi,

need some guidance or pointers on this matter.

Scenario:
1. A HTML Submit Button exists on subdomain (A Demo site)
<div><form action="http://mymaindomain.com/cforderformlinkhere" method="post" target="_blank">
<p><input name="order_prodnamexx" value="Order" type="submit" /></p>
</form></div>>

2. Each Product Detail Page contains a different name on the Submit button, related to the product
3. Somehow I need to carry that data to the Main Domain ChronoForms - Order Form so that it automatically populates a Drop-Down field in the CF - Order Form

Is this the right way to go, or are there easier ways to achieve this?

(Purpose is to pre-populate Ordering Form with productname and not make the user "fill in/give" same info twice)

Main Domain and Sub Domain have different databases.
Even if I use CF on both Domains, I will probably not be able to retrieve data. Right?
In order to build a COMPLETE ordering form this would probably be the best solution, since I then could use any Table/Field from the Demo Site (Sub Domain) to populate the Order Form.
(But then Order Form need to be in the Sub Domain...hmm)

...as you can see... I'm a bit confused on what way to go... and how. :wink:

Any feedback is welcome... even a slap on the head.

Regards
Akerman
nml375 16 Nov, 2010
Hi Akerman,
Given the conditions you stated, the simplest way to transfer the information would be a form submission, much like you've implemented your subdomain page already.

The next step would be to read this information in your Form HTML code, and then pre-fill the form input. The way you've implemented the subdomain form, with different form field names, as opposed to values, does mean that we have to drop the usual JRequest::getVar() method, and instead use something like this:
...<select name="somethign>
<option value="article1"<? echo array_key_exists("order_prodname1", $_POST)?' selected':''; ?>>Article 1</option>
<option value="article2"<? echo array_key_exists("order_prodname2", $_POST)?' selected':''; ?>>Article 1</option>
...
</select>


array_key_exists simply checks whether the given key (form field name) exists within the array (POST form data), and returns true or false.
The [test]?[iftrue]:[iffalse] construct is a simplified if-conditional, which will return either the [iftrue] or [iffalse] value. This could also be written along the lines of:
if (array_key_exists("order_prodname1", $_POST))
{
  echo '<option value="article1" selected>Article 1</option>';
} else {
  echo '<option value="article1">Article 1</option>';
}


You might be able to have either your subdomain form connect to the mainsite database (or other way around), and transfer the data that way - Depending on server setups. Even so, I would not recommend this approach, as this would require quite an effort to make sure the right value is associated with the right user session.

/Fredrik
akerman 17 Nov, 2010
Hi,

..just the inspiration I needed. Thanks!

Your solution works fine and I've tested it.

Although your comment about Joomla JRequest Class made me think and read some more...
so I implemented this structure instead, thereby getting some protection against injections and following the Joomla structure. 😀

<div class="form_item">
<?php
$orderproduct = JRequest::getVar('orderproduct', 'default value goes here - if missing', 'post');
echo $order2gosite;
?>
</div>

(No styling added yet..)

Your reply was greatly appreciated!

Thanks!
Robert O. Akerman

-------------------------------------------------------------------------------------------------
This might be some good reading for anyone looking to include data "on-the-fly" into a form:
http://greyhead.net/how-to-docs/chronoapplication
GreyHead 17 Nov, 2010
Hi Robert,

Just a footnote to Fredrik's reply. It is possible to access a second (or more) database from Joomla! Search here on db2 for some examples.

Bob
akerman 17 Nov, 2010
Hi Bob,

thanks for the tip... way ahead of you though..😀

Read all that yesterday, and yes.. the more I use CF the more I realize what powerful tool you guys created. Really helpful.

(FYI, this ordering process also populates our vTiger CRM... which later on hopefully will create nice PDF invoices... as soon as I can get my head around PDF creations in vTiger. There are some tools that can aid with that... and I've already made PDF invoices for Phoca's Virtuemart solution... so soon.. 😀 )

Thanks again for alert replies and a very nice product!

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