Hello,
Sorry for this stupid question, I'm not a PHP expert.
I would like to populate a drop down list with data located within a joomla table (from "Seminar" component) to choose one event.
I created my form,
Is there somewhere a tutorial (I found many interesting contributions bur not what I'm looking for) explaining how populate this drop down box and how to select a value (or multiple values).
Thanks in advance
Sorry for this stupid question, I'm not a PHP expert.
I would like to populate a drop down list with data located within a joomla table (from "Seminar" component) to choose one event.
I created my form,
Is there somewhere a tutorial (I found many interesting contributions bur not what I'm looking for) explaining how populate this drop down box and how to select a value (or multiple values).
Thanks in advance
Hi cobayecrau,
Welcome :-)
You'll need something like this in your form html:
Bob
PS Depending on what you want to do with this the ChronoForms Profile PlugIn might also be useful
Welcome :-)
You'll need something like this in your form html:
<?php
$db =& JFactory::getDBO();
$query = "
SELECT field_name
FROM `#__table_name`;
$db->setQuery($query);
$rows = $db->loadResultList();
?>
. . .
<select . . . >
<?php
foreach ($rows as $row) {
echo "<option value='$row'>$row</option>";
}
?>
</select>
. . .
Bob
PS Depending on what you want to do with this the ChronoForms Profile PlugIn might also be useful
Thank you Bob,
I'm not very clever; I don't understand where I can put this code in my form.
See my form below.
We assume for this example we are speaking about this dropdown
cf_inputbox validate-selection" id=select_3 size=1 name=select_3
The table name is "jos_seminar" and the field I want to populate is "title"
I think with an example I can do the job for the others drop down boxes.
I'm not very clever; I don't understand where I can put this code in my form.
See my form below.
We assume for this example we are speaking about this dropdown
cf_inputbox validate-selection" id=select_3 size=1 name=select_3
The table name is "jos_seminar" and the field I want to populate is "title"
I think with an example I can do the job for the others drop down boxes.
<DIV class=form_item >
<DIV class="form_element cf_heading" >
<H1 class=cf_text id="" >Feuille de Palanquée</H1></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >sélectionner un événement</LABEL><SELECT class="cf_inputbox validate-selection" id=select_3 size=1 name=select_3 ><OPTION value="option 1" selected >option 1</OPTION><OPTION value="option 2" >option 2</OPTION><OPTION value="option 3" >option 3</OPTION></SELECT></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >sélectionner un directeur de plongée</LABEL><SELECT class=cf_inputbox id=select_4 size=1 name=select_4 ><OPTION value="option 1" selected >option 1</OPTION><OPTION value="option 2" >option 2</OPTION><OPTION value="option 3" >option 3</OPTION></SELECT></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Palanquée n° :</LABEL><INPUT class="cf_inputbox required validate-digits" id=text_5 maxLength=2 size=2 name=text_5 ><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Palanquée n° : :: Numéro d'ordre de la palanquée</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >Sélectionner le guide :</LABEL><SELECT class=cf_inputbox id=select_6 size=1 name=select_6 ><OPTION value="option 1" selected >option 1</OPTION><OPTION value="option 2" >option 2</OPTION><OPTION value="option 3" >option 3</OPTION></SELECT><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Sélectionner le guide : :: Guide ou moniteur</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >Sélectionner les plongeurs</LABEL><SELECT class=cf_inputbox id=select_7 multiple size=4 name=select_7[] ><OPTION value="option 1" >option 1</OPTION><OPTION value="option 2" >option 2</OPTION><OPTION value="option 3" >option 3</OPTION><OPTION value="option 4" >option 4</OPTION></SELECT><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Sélectionner les plongeurs :: Sélectionner au plus 4 plongeurs utilisez les touches <CTRL><C></DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Heure de départ</LABEL><INPUT class="cf_inputbox required validate-date" id=text_8 maxLength=10 size=10 name=text_8 ></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Heure de sortie</LABEL><INPUT class="cf_inputbox validate-date" id=text_9 maxLength=10 size=10 name=text_9 ></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Palier à 3 m :</LABEL><INPUT class="cf_inputbox validate-number" id=text_10 maxLength=150 size=30 name=text_10 ><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Palier à 3 m : :: saisir la durée du palier en mn</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Palier à 6 m :</LABEL><INPUT class="cf_inputbox validate-number" id=text_11 maxLength=150 size=30 name=text_11 ><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Palier à 6 m : :: Saisir la durée du palier à 6 m</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textarea" ><LABEL class=cf_label >Commentaires :</LABEL><TEXTAREA class=cf_inputbox id=text_12 name=text_12 rows=3 cols=30 ></TEXTAREA><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Commentaires : :: Saisir ici vos commentaires, objet de la plongée, faits marquants</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_button" ><INPUT type=submit value=Submit ></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_button" ><INPUT type=submit value=Submit ></DIV>
<DIV class=clear > </DIV></DIV>
Hi,
I will edit one of the code blocks:
Cheers
Max
I will edit one of the code blocks:
<DIV class=form_item >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >sélectionner un événement</LABEL>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT title
FROM `jos_seminar`;
$db->setQuery($query);
$rows = $db->loadResultList();
?>
<SELECT class="cf_inputbox validate-selection" id=select_3 size=1 name=select_3 >
<?php
foreach ($rows as $row) {
echo "<option value='$row'>$row</option>";
}
?>
</select>
</DIV>
<DIV class=clear > </DIV></DIV>
Cheers
Max
Hello,
I checked what you gave me but without success, I get the following error when I try to launch the form by clicking on it via the backend panel
Fatal error: Call to undefined method JDatabaseMySQL::loadResultList() in F:\xampp\htdocs\cap2009\components\com_chronocontact\chronocontact.html.php(320) : eval()'d code on line 15
I checked what you gave me but without success, I get the following error when I try to launch the form by clicking on it via the backend panel
Fatal error: Call to undefined method JDatabaseMySQL::loadResultList() in F:\xampp\htdocs\cap2009\components\com_chronocontact\chronocontact.html.php(320) : eval()'d code on line 15
<DIV class=form_item >
<DIV class="form_element cf_heading" >
<H1 class=cf_text id="" >Feuille de Palanquée</H1></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_dropdown" >
<LABEL class=cf_label >sélectionner un événement</LABEL>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT title
FROM jos_seminar";
$db->setQuery($query);
$rows = $db->loadResultList();
?>
</DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_dropdown" >
<LABEL class=cf_label >sélectionner un directeur de plongée</LABEL>
<SELECT class=cf_inputbox id=select_4 size=1 name=select_4 >
<OPTION value="option 1" selected >option 1</OPTION>
<OPTION value="option 2" >option 2</OPTION>
<OPTION value="option 3" >option 3</OPTION>
</SELECT>
</DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Palanquée n° :</LABEL><INPUT class="cf_inputbox required validate-digits" id=text_5 maxLength=2 size=2 name=text_5 ><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Palanquée n° : :: Numéro d'ordre de la palanquée</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >Sélectionner le guide :</LABEL><SELECT class=cf_inputbox id=select_6 size=1 name=select_6 ><OPTION value="option 1" selected >option 1</OPTION><OPTION value="option 2" >option 2</OPTION><OPTION value="option 3" >option 3</OPTION></SELECT><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Sélectionner le guide : :: Guide ou moniteur</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >Sélectionner les plongeurs</LABEL><SELECT class=cf_inputbox id=select_7 multiple size=4 name=select_7[] ><OPTION value="option 1" >option 1</OPTION><OPTION value="option 2" >option 2</OPTION><OPTION value="option 3" >option 3</OPTION><OPTION value="option 4" >option 4</OPTION></SELECT><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Sélectionner les plongeurs :: Sélectionner au plus 4 plongeurs utilisez les touches <CTRL><C></DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Heure de départ</LABEL><INPUT class="cf_inputbox required validate-date" id=text_8 maxLength=10 size=10 name=text_8 ></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Heure de sortie</LABEL><INPUT class="cf_inputbox validate-date" id=text_9 maxLength=10 size=10 name=text_9 ></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Palier à 3 m :</LABEL><INPUT class="cf_inputbox validate-number" id=text_10 maxLength=150 size=30 name=text_10 ><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Palier à 3 m : :: saisir la durée du palier en mn</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Palier à 6 m :</LABEL><INPUT class="cf_inputbox validate-number" id=text_11 maxLength=150 size=30 name=text_11 ><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Palier à 6 m : :: Saisir la durée du palier à 6 m</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_textarea" ><LABEL class=cf_label >Commentaires :</LABEL><TEXTAREA class=cf_inputbox id=text_12 name=text_12 rows=3 cols=30 ></TEXTAREA><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Commentaires : :: Saisir ici vos commentaires, objet de la plongée, faits marquants</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_button" ><INPUT type=submit value=Submit ></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_button" ><INPUT type=submit value=Submit ></DIV>
<DIV class=clear > </DIV></DIV>
Hi cobayecrau,
What code are you using? I'm sure this - JDatabaseMySQL::loadResultList() -wasn't in anything Max posted. It's not meaningful Joomla code.
Bob
What code are you using? I'm sure this - JDatabaseMySQL::loadResultList() -wasn't in anything Max posted. It's not meaningful Joomla code.
Bob
Hello,
If I only paste the code from Max and execute it I get
Parse error: parse error in F:\xampp\htdocs\cap2009\components\com_chronocontact\chronocontact.html.php(320) : eval()'d code on line 12
I don't understand why you don't close the SQL request with quotes "
and why you write `jos_seminar` instead of jos_seminar ?
If I only paste the code from Max and execute it I get
Parse error: parse error in F:\xampp\htdocs\cap2009\components\com_chronocontact\chronocontact.html.php(320) : eval()'d code on line 12
I don't understand why you don't close the SQL request with quotes "
and why you write `jos_seminar` instead of jos_seminar ?
<DIV class=form_item >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >sélectionner un événement</LABEL>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT title
FROM `jos_seminar`;
$db->setQuery($query);
$rows = $db->loadResultList();
?>
<SELECT class="cf_inputbox validate-selection" id=select_3 size=1 name=select_3 >
<?php
foreach ($rows as $row) {
echo "<option value='$row'>$row</option>";
}
?>
</select>
</DIV>
<DIV class=clear > </DIV></DIV>
Well, those are typos!! it was too late when I did this and I didn't recheck the code!! 🙂
you need to close the query string :
Cheers
Max
you need to close the query string :
$query = "SELECT title FROM `jos_seminar`;"
Cheers
Max
Hi cobayecrau,
`jos_seminar` is correct - MySQL names should be enclosed in back-ticks and values in 'value' single quotes
Bob
PS Though to be good Joomla that should be `#__seminar` to let Joomla set the table prefix :-)
`jos_seminar` is correct - MySQL names should be enclosed in back-ticks and values in 'value' single quotes
Bob
PS Though to be good Joomla that should be `#__seminar` to let Joomla set the table prefix :-)
Hello.
I've follow this tread because I've the same problem, and searching, I found thatloadResultList seems doesn't exist...
Maybe change this the code will be correct....???
Sorry for my bad english...
I've follow this tread because I've the same problem, and searching, I found thatloadResultList seems doesn't exist...
Maybe change this the code will be correct....???
Sorry for my bad english...
Thanks so much Bob!!!
Now it's working ok... my next step it's to fill a textfield depending a select value for my drop down list hehehe
Thank you again!
Now it's working ok... my next step it's to fill a textfield depending a select value for my drop down list hehehe
Thank you again!
Ok, I've populate my dropdown with this code, but now, i want to add data to a text field when I select a element ffor my dropdown list....
Example, my table "friends" have te data "name", "age", "address", so on... I populate my dropdown list with "name", when I select Karla, text field "addres", "age" and "x" filled up with data form Karla....
I've seen so many examples in php and js but I'm really lost... have somebody any idea about this??
Thanks!
Example, my table "friends" have te data "name", "age", "address", so on... I populate my dropdown list with "name", when I select Karla, text field "addres", "age" and "x" filled up with data form Karla....
I've seen so many examples in php and js but I'm really lost... have somebody any idea about this??
Thanks!
Hi Rias,
you will need to create a dynamic JS function and use the onChange event of the select element to load the data in the 2 fields, this is alittle advanced!
Regards,
Max
you will need to create a dynamic JS function and use the onChange event of the select element to load the data in the 2 fields, this is alittle advanced!
Regards,
Max
Hello,
Here is my last release and it works fine.
Than you, you're very helpful.
Of course you can tune your sql request as you wish.
Here is my last release and it works fine.
Than you, you're very helpful.
Of course you can tune your sql request as you wish.
<DIV class=form_item >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >sélectionner un événement</LABEL>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM #__seminar ";
$db->setQuery($query);
$rows = $db->loadResultArray(4);
?>
<SELECT class="cf_inputbox validate-selection" id=select_3 size=3 name=select_3 >
<?php
foreach ($rows as $current) {
echo "<option value='$row'>$current</option>";
}
?>
</select>
</DIV>
<DIV class=clear > </DIV></DIV>
Hi cobayecrau,
This doesn't look quite right:
Bob
This doesn't look quite right:
foreach ($rows as $current) {
echo "<option value='$row'>$current</option>";
}
I don't think that $row is defined. Perhaps it should be:foreach ($rows as $row => $current) {
echo "<option value='$row'>$current</option>";
}
Bob
Good idea !
Nevertheless I think $row and $current are already defined as keywords for PhP (not sure ?)
Nevertheless I think $row and $current are already defined as keywords for PhP (not sure ?)
No, I dont think so!🙂
Max
Max
hi, Im looking at the population of the dropdown aswell which ive managed to get working (thanks🙂)
how do i get the text of the option from a different column in the database but for the same row. so that the option will have a value which is different to what is displayed to the user.
example:
thanks,
sam.
how do i get the text of the option from a different column in the database but for the same row. so that the option will have a value which is different to what is displayed to the user.
example:
<SELECT >
<option value='$id'>$name_of_person</option>
</select>
thanks,
sam.
Hi smappler,
Did you use the code I posted at the other topic ? you can edit it very easily to do this!
Cheers
Max
Did you use the code I posted at the other topic ? you can edit it very easily to do this!
Cheers
Max
I want to do the same thing. I understand how to create the php code. The problem is that I can't find the file to put the code into. My form I have created is called eventreg. I've looked under the componants/com_chronocontact and cannot find a file name of eventreg. Can someone tell me where the file resides so that I can make the changes?
Thanks. Love the software! I paid the $25 just because it is well worth it!!
Anne
Thanks. Love the software! I paid the $25 just because it is well worth it!!
Anne
Hi Anne,
To add code to your form - or to edit the Form HTML, open the form in the ChronoForms Form Manager and click the Form Code tab. You can open or close individual widows by clicking the +- signs.
Bob
To add code to your form - or to edit the Form HTML, open the form in the ChronoForms Form Manager and click the Form Code tab. You can open or close individual widows by clicking the +- signs.
Bob
I am trying to do about the same but since I might want to add columns in my table I tried with loadAssocList instead.
When I try to print this out in the form as a drop-down I only get multiple choices with the text "Array" in it. This is the code for output:
Anybody that can shine any light on this problem? I am a total noob at php.
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM #__users";
$db->setQuery($query);
$rows = $db->loadAssocList('username');
?>
When I try to print this out in the form as a drop-down I only get multiple choices with the text "Array" in it. This is the code for output:
<?php
foreach ($rows as $row => $current) {
echo "<option value='$row'>$current</option>";
}
?>
Anybody that can shine any light on this problem? I am a total noob at php.
try loadRowList instead ?
Max
Max
Same result. I am doing something wrong. It works perfectly with loadResultArray...
Guess I need to stick with that. Thanks for your help.
Guess I need to stick with that. Thanks for your help.
oh, my mistake, yes, your code supports only 1 array, so you should use the loadResultArray!
Regards
Max
Regards
Max
How ould I do if I want the resulting values in the form to be unique?
I tried with "DISTINCT" in the sql-query but it seems to go through all columns.
Edit:
Found it out myself. "GROUP BY column_name" worked the charn in the sql-query.
I tried with "DISTINCT" in the sql-query but it seems to go through all columns.
Edit:
Found it out myself. "GROUP BY column_name" worked the charn in the sql-query.
I was happy when it seemed to work but my tables are not created correctly.
This is my code:
This is connected to a table. The form is populated correctly (with the array from "jos_chronoforms_tavlingar") but when I send the form the value inserted in the table is not correct (it is a number although the populated value is text).
Any clues on this?
This is my code:
<div class="form_item">
<div class="form_element cf_heading">
<h1 class="cf_text">Anmäl tävlingsfiskare</h1>
</div>
<div class="clear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label">Tävling</label>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM #__chronoforms_tavlingar";
$db->setQuery($query);
$rows = $db->loadResultArray(5);
?>
<select class="cf_inputbox validate-selection" id="select_1" size="1" name="tavlingsklubb">
<?php
foreach ($rows as $row => $current) {
echo "<option value='$row'>$current</option>";
}
?>
</select>
</div>
<div class="clear"> </div>
</div>
This is connected to a table. The form is populated correctly (with the array from "jos_chronoforms_tavlingar") but when I send the form the value inserted in the table is not correct (it is a number although the populated value is text).
Any clues on this?
Hi crisscross.
I don't recognise $rows = $db->loadResultArray(5); what's the '5'?
You are setting the array index as the value of the option so it will be a number.
Bob
I don't recognise $rows = $db->loadResultArray(5); what's the '5'?
You are setting the array index as the value of the option so it will be a number.
Bob
Hi crisscross.
I don't recognise $rows = $db->loadResultArray(5); what's the '5'?
You are setting the array index as the value of the option so it will be a number.
Bob
The '5' chooses column 5 in the database. The problem seemed to be with the <option value='$row'> as $row only defined the indice number as you said. I changed it to <option value='$current'> so the code is:
<?php
foreach ($rows as $row => $current) {
echo "<option value='$current'>$current</option>";
}
?>
I have no idea if that is the correct way of doing it but it works!
Thank you!
Hi crisscross,
And, yes, using $current for the value is the right thing to do here.
Bob
You are setting the array index as the value of the option so it will be a number.
Oh dear - my memory is fading - I wrote the section in the Joomla Wiki that explains exactly how to use that syntax :-(And, yes, using $current for the value is the right thing to do here.
Bob
Hi,
sorry to up an old thread.
I did try the snippets provided here, but ended up with a blank page.
I'm using a temporary solution with javascript linked dropdown list.
original form code:
Can someone explain it to me about the blank screen?
Thanks
sorry to up an old thread.
I did try the snippets provided here, but ended up with a blank page.
I'm using a temporary solution with javascript linked dropdown list.
original form code:
<div class=form_item >
<div class="form_element cf_dropdown" ><label class="cf_label" style="width: 150px;">Gerätetyp:</label>
<?php
$db =& JFactory::getDBO();
$query = "SELECT devicetype FROM `#__my_device`;"
$db->setQuery($query);
$rows = $db->loadResultArray();
?>
<select class="cf_inputbox validate-selection" id="select_1" title="test" size=1 name="select_3" >
<?php
foreach ($rows as $row) {
echo "<option value='$row'>$row</option>";
}
?>
</select>
</div>
<div class="cfclear"> </div>
</div>
Can someone explain it to me about the blank screen?
Thanks
Hi diva,
The code basically looks OK. It's better not to use $rows or $row as Joomla also uses these values and that may be why your page is getting messed up. Try $devices and $device instead.
The next step is to set Error Reporting to Maximum in the Site Global Configuration and see if you get a meaningul error message instead of a blank page.
Bob
The code basically looks OK. It's better not to use $rows or $row as Joomla also uses these values and that may be why your page is getting messed up. Try $devices and $device instead.
The next step is to set Error Reporting to Maximum in the Site Global Configuration and see if you get a meaningul error message instead of a blank page.
Bob
Hi GreyHead.
Again i'm amazed on how the support is being put up from Chronoform. *****
This is the error i got
Parse error: syntax error, unexpected T_STRING in /Applications/MAMP/htdocs/sandbox/components/com_chronocontact/chronocontact.html.php(180) : eval()'d code on line 4
This is the modified form codes as you suggested
Again i'm amazed on how the support is being put up from Chronoform. *****
This is the error i got
Parse error: syntax error, unexpected T_STRING in /Applications/MAMP/htdocs/sandbox/components/com_chronocontact/chronocontact.html.php(180) : eval()'d code on line 4
This is the modified form codes as you suggested
<div class=form_item >
<div class="form_element cf_dropdown" ><label class="cf_label" style="width: 150px;">Gerätetyp:</label>
<?php
$db =& JFactory::getDBO();
$query = "SELECT devicetype FROM `#__my_device`;"
$db->setQuery($query);
$rows = $db->loadResultArray();
?>
<select class="cf_inputbox validate-selection" id="select_1" title="test" size=1 name="select_3" >
<?php
foreach ($devices as $device) {
echo "<option value='$device'>$device</option>";
}
?>
</select>
</div>
<div class="cfclear"> </div>
</div>
Hi diva,
Hmmm . . . you need to change this line too
and the error is becasue there is a semi-colon missing from the end of this line
Bob
Hmmm . . . you need to change this line too
$rows = $db->loadResultArray();
to$devices = $db->loadResultArray();
and the error is becasue there is a semi-colon missing from the end of this line
$query = "SELECT devicetype FROM `#__my_device`;";
Bob
<div class=form_item>
<div class="form_element cf_dropdown" ><label class="cf_label" style="width: 150px;">Gerätetyp:</label>
<?php
$db =& JFactory::getDBO();
$query = "SELECT devicetype FROM `#__my_device`;";
$db->setQuery($query);
$devices = $db->loadResultArray();
?>
<select class="cf_inputbox validate-selection" id="select_1" title="test" size=1 name="select_3" >
<?php
foreach ($devices as $device) {
echo "<option value='$device'>$device</option>";
}
?>
</select>
</div>
<div class="cfclear"> </div>
</div>
yup still got the same error message
Hi diva,
Hmmmm ... I don't see anything else in there. Please make sure that the update is saved then re-load the form page.
Bob
Hmmmm ... I don't see anything else in there. Please make sure that the update is saved then re-load the form page.
Bob
Hi Diva,
Please re-post the current Form HTML and the error message you are getting.
Bob
Please re-post the current Form HTML and the error message you are getting.
Bob
(Sorry if this is repeated somewhere, but I looked for hours and finally figured this out on my own)
This code works for selecting a registered person from a dropdown box. As an admin, I needed a way to attach a user id to records in a meeting database as I was inputting the entries. With the code below, I can add a user to the meeting with their id loaded to the cf_user_id field in the database, and then allow each person to call up their list of meetings with ChronoConnect, editing as needed:
The only issue is that if we did not want user ids out in the public, this is a security hole when someone views the source code. Since this site is closed to public registration, it would be difficult for someone to do this, however it is possible an important issue to discuss.
Thanks,
Yahhr
This code works for selecting a registered person from a dropdown box. As an admin, I needed a way to attach a user id to records in a meeting database as I was inputting the entries. With the code below, I can add a user to the meeting with their id loaded to the cf_user_id field in the database, and then allow each person to call up their list of meetings with ChronoConnect, editing as needed:
<select class="cf_inputbox validate-selection" id="cf_user_id" size="1" title="" name="cf_user_id">
<option value="">Choose Employee</option>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM #__users ";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
echo "<option value='$row->id'>$row->name</option>";
}
?>
</select>
The only issue is that if we did not want user ids out in the public, this is a security hole when someone views the source code. Since this site is closed to public registration, it would be difficult for someone to do this, however it is possible an important issue to discuss.
Thanks,
Yahhr
Hi Yahhr,
The code is here several times but that's a perfectly good version of it.
Bob
The code is here several times but that's a perfectly good version of it.
Bob
Ok I wondered, because all the ones I see (and have tried) load the same variable in value and visible text in the pull-down menu. This one loads the variable ([user_id] from jos_user) in the value, and the name of the person ([name] from jos_user) in the visible pull-down. Maybe I am blind (age does that), but I certainly do not see this form of this code snippet anywhere in here.
My apologies!
My apologies!
This topic is locked and no more replies can be posted.