select box

chrissy6930 18 Jun, 2011
Hi all,

I have 2 tables, events & venues and would like to populate field locid (select box) in form events with data from the venues table

I tried editing the respective snippet in the form html for:

<div class="ccms_form_element cfdiv_select" id="veranstaltungsort_container_div"><label>Veranstaltungsort</label><select size="10" class=" validate['required']" title="" type="select" name="locid">
<option value="">- Bitte auswählen -</option>
<?php
$db =& JFactory::getDBO();
$query = 'SELECT * FROM #__chronoforms_data_venues ORDER BY `town`, `venue`';
$db->setQuery( $query );
$venues = $db->loadObjectList();
foreach ( $venues AS $venue) {
  $option  = $venue->town;
  if ($venue->venue) $option .= ', '. $venue->venue;
  echo "<option value='" . $venue->cf_id . "'>" . $option . "</option>";
} ?>
</select>

this however is not working at all. although there are entries in the venues table the list is not being populated. var_dumpin $venues does not return anything either.

could somebody please help me out?

J!1.5.23, CF4 RC1.9
Max_admin 20 Jun, 2011
Hi Chrissy,

You are saying that the $venues variable is empty ? if so then the best thing is to test your query on PHPmyadmin to find out why it doesn't work, maybe an error or empty table, for me it looks fine.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
chrissy6930 20 Jun, 2011
Hi Max,

yes var_dumping $venues is not returning anything not even 'NULL'
the query is working fine in phpmyadmin (pls see screen venues)
and as you said there is no syntax error in my code

I am majorly confused why its not working :?
Max_admin 21 Jun, 2011
Hi chrissy,

please remove the ORDER part from the query in PHP and retest.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
chrissy6930 21 Jun, 2011
unfortunately that's not making any difference either
bramya 05 Oct, 2011
hi
i am also using the drop down box in chronoform v3 by php code.I fetched the table details into the list,i have to update its id into another table which corresponds to the form.
whether i have to use onchange event or something else.Also help me where to add that event.
thanks in advance,
Max_admin 05 Oct, 2011
Hi bramya,

I'm not sure what you are trying to do, could you please give us more details to better understand the issue in a new forum post under the correct forums section ? because this is the CF V4 only section🙂

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
bramya 10 Oct, 2011
hi
Now,I am using chronoform v4 in joomla1.7.I used some code to fetch a column from a table into drop down box.
when i select the option from that dropdown,
1.Its "id" in the corresponding table should be inserted into form table.
2.based on selection,some other text boxes and select boxes should loaded into form.

Give your suggestions for this.I am confused have to use onchange event or some other codes..

Thanks in advance,
bramya 11 Oct, 2011
any one help me to insert "id" of dropdown list which is selected?🤨
how to give custom code for that in Onsubmit action?
GreyHead 11 Oct, 2011
Hi bramya,

I can't answer this from the information here.

Usually I'd put the id in the option 'value', that way it's available after the form is submitted.

Bob
Rolfo 12 Oct, 2011
For anyone who want to use the above droplist php:

Add () parentheses to line 8 so that it states: $venues = $db->loadObjectList();
Then the php for populating a select box is functioning well.

<select size="1" class=" validate['required']" title="" type="select" name="debiteurenlijst">
<option value="">- debiteurenlijst -</option>
<?php
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__tablename";
$db->setQuery( $query );
$debiteuren = $db->loadObjectList();
foreach($debiteuren AS $debiteur)
{
  $option  = $debiteur->deb_snellenaam;
  echo "<option value='" . $debiteur->id_userinfo_deb . "'>" . $option . "</option>";
}
?>
</select>
bramya 18 Oct, 2011
I am using the select box in chronoform v4 which Displays the categories from category table.
Now,my need is that i have to include the category id of the selected category into "chronoform1" table..

Anyone help me with your ideas.
thanks in advance,
GreyHead 18 Oct, 2011
Hi bramya,

Usually I'd put the id in the option 'value', that way it's available after the form is submitted.


Bob
bramya 20 Oct, 2011
I got it what you are saying.But i dono how to implement the same for my form.The following foreach loop displays the category names
foreach ( $options as $o ) {
  echo "<option value='".$o[id]."'>".$o[name]."</option>";

after selecting the name, i want to insert its id into chronoform product table.. 😟
help me for this.
thanks in advance,
GreyHead 20 Oct, 2011
Hi Bramya,

If you set up the select box like this then a normal DB Save will add the selected value of the option, the ID, to the database table. If you mean that you want to save the name instead then use a Custom Code action to look up the name using the submitted ID.

Bob
Ritchie 15 Nov, 2011

If you mean that you want to save the name instead then use a Custom Code action to look up the name using the submitted ID.



Bob, This is something that i also need. I wan't to save the ID and Title (http://www.chronoengine.com/forums.html?cont=posts&f=2&t=27326), but i can't figure out how. I search the forum for examples but can't get the puzzle solved.

<select size="1" type="select" name="producten">
<option value="">-------- producten --------</option>
<?php
$db =& JFactory::getDBO();
$query = "SELECT id,title FROM lw0bd_faqbook_items ORDER BY title";

$db->setQuery( $query );
$option = $db->loadObjectList();

foreach ( $option as $o) {
   echo "<option value='{$o->id}' >{$o->title}</option>";
}

?>


I am sorry to "spam" you like this 😶 😶 but i really hope you can help me
GreyHead 15 Nov, 2011
Hi Ritchie,

Personally I'd just save the ID and look up the title when I needed it later.

If you want to save both then you have two choices. The form will only return the Option value, so you can either add the title into the value e.g.
echo "<option value=\"{$o->id}|{$o->title}\" >{$o->title}</option>";
- but then you have to 'un-pack' it before saving; or you can look the title up after the form is submitted. I'd probably take the second choice.

Bob
Ritchie 15 Nov, 2011
Hi Bob, thnx for your reply. Where do i begin if i want to look the title up after the form is submitted?? I need a extra custom code...but then?
GreyHead 15 Nov, 2011
Hi Ritchie,

More or less the same query as before:. This should add the title to form results:
<?php
$db =& JFactory::getDBO();
$query = "
  SELECT title FROM `#_faqbook_items` 
  WHERE `id = '{$form->data['producten']}';
";
$db->setQuery( $query );
$form->data =['title'] = $db->loadResult();
?>

Bob
Ritchie 15 Nov, 2011
Hi Bob,

Thnx again for you'r reply but i'am still missing my goal.

After the selection i press submit. After the submit i send a email with {producten} as variable.
Now, as it is, it shows the "id"... but i wanne send the "title" in the email (not the "id").

The "id" i need for linking the "title" to a url... so i really need both.. :?

Hi Ritchie,
More or less the same query as before:. This should add the title to form results:

<?php
$db =& JFactory::getDBO();
$query = "
  SELECT title FROM `#_faqbook_items` 
  WHERE `id = '{$form->data['producten']}';
";
$db->setQuery( $query );
$form->data =['title'] = $db->loadResult();
?>

Bob

GreyHead 15 Nov, 2011
Hi Ritchie,

Put {title} in the email to get the title.

Bob
Ritchie 16 Nov, 2011

Hi Ritchie,
Put {title} in the email to get the title.
Bob



Hi Bob, sadly that doens't work.
I debugged the form:

Data Array: 
Array
(
[naammelder] => sdfsdfsd
[producten] => 186
[omschrijving] => sdfsdf
[status] => Open
[cf_id] => 
[input_submit_1] => Submit
[34cacf1df07b2c02f515b02ff6189ee2] => 1
[option] => com_chronoforms
[chronoform] => productwijzigen
[event] => submit
[Itemid] => 
)
Data Array: 
Array
(
[naammelder] => sdfsdfsd
[producten] => 186
[omschrijving] => sdfsdf
[status] => Open
[cf_id] => 
[input_submit_1] => Submit
[34cacf1df07b2c02f515b02ff6189ee2] => 1
[option] => com_chronoforms
[chronoform] => productwijzigen
[event] => submit
[Itemid] => 
[chronoform_data] => Array
(
[cf_uid] => f1e9ce815e0a9b009f2ecfe559d719e1
[cf_created] => 2011-11-16 09:03:10
[cf_ipaddress] => 172.16.7.233
[cf_user_id] => 0
[naammelder] => sdfsdfsd
[producten] => 186
[omschrijving] => sdfsdf
[status] => Open
[cf_id] => 26
[input_submit_1] => Submit
[34cacf1df07b2c02f515b02ff6189ee2] => 1
[option] => com_chronoforms
[chronoform] => productwijzigen
[event] => submit
[Itemid] => 
)
[chronoform_data_cf_id] => 26
)
Debug Data
An email has been SENT successfully from (TiP)0-DienstverleningReceptie@soest.nl to appl_puza@soest.nl
Email template:

Nieuwe registratie TiP portaal
Er is een nieuwe registratie binnengekomen m.b.t. wijzigen product in het TiP portaal.

Gegevens registratie
Naam melder: 	 sdfsdfsd
Product: 	{title}
Omschrijving: 	 sdfsdf


In the wizard it looks like this, i put your code after the submit in a costum code:
[attachment=0]formwizard-title.jpg[/attachment]

For your notification, the "DB Record Loader" goes to another table where the data for the form is actually is saved ("lw0bd_chronoforms_data_producttoevoegen").

The dropdown box is pulled from "lw0bd_faqbook_items" and this is where i wan't the id en title of.
Ritchie 16 Nov, 2011
Hi Bob,

The problem is solved with your first option (<option value=\"{$o->id}|{$o->title}\" >{$o->title}</option>)

Appearantly if i connect the value of the option to a url it does work (index.php?option=com_faqbook&view=item&layout=edit&id=11 | Aanlegvergunning).

It is not nice, but it does the job (and i don't wanne bother this with you any more 😶 :wink: )

Many thnx for the support.
This topic is locked and no more replies can be posted.