Hello,
I'm trying to apply the soluces given by Bob
when I have a look at the table I get this
cf_id uid recordtime ipaddress cf_user_id text_5 text_8 text_9 text_10 text_11 select_3 select_4 select_5 select_6 text_12
6 INzUwMGJiZTdlNzkx 2009-02-09 - 15:02:52 127.0.0.1 0 X 05:05 06:06 10 0 1 69 68 commentaire 11
7 IZjViMjU0YTRhMjY4 2009-02-09 - 15:03:34 127.0.0.1 0 Z 14:14 15:15 15 1 67 commentaire 12
During my previous test with only one form, select_6 which is an area was correctly filled (65,66,67 ie), now there is nothing but the debug mode shows there is something in the area
What I wish is to fill select_3 and select_4 on the form1, and to prepopulate in readonly text_5 with the number of page (here text_5 = 1) of course I choose values for the other fields select5 select_6 text_xx
I wish form n+1 prepopulate with the select_3, select_4 values previouslty chhosen in form1, text_5 becomes 2 and I fill the other fields.
I want one record per form with all the data of the form.
And last question how to break the loop, may be with an other submit button ?
Code form
<?php
$page = JRequest::getInt('page', '0', 'post');
$page++; // to get the current page
switch ($page) {
case 1:
?>
// show code for page 1 here
<input type='hidden' name='page' value='1' />
<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 id, title
FROM #__seminar WHERE NOW() > end ";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
<SELECT class="cf_inputbox validate-selection" id=select_3 size=3 name=select_3 >
<?php
foreach ( $rows as $row )
{
echo "<option value='".$row->id."' >".$row->title."</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>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM ".$db->nameQuote('#__users')." a
INNER JOIN ".$db->nameQuote('#__comprofiler')." b
ON ( a.id = b.id )
WHERE ( b.cb_niveauencadrement != '' )";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
<SELECT class="cf_inputbox validate-selection" id=select_4 size=3 name=select_4 >
<?php
foreach ($rows as $row)
{
echo "<option value='".$row->id."' >".$row->name."</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>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM ".$db->nameQuote('#__users')." a
INNER JOIN ".$db->nameQuote('#__comprofiler')." b
ON ( a.id = b.id )
WHERE ( b.cb_niveauencadrement != '' )
OR ( b.cb_niveauplongeur = 'Niveau 4' )";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
<SELECT class="cf_inputbox validate-selection" id=select_5 size=3 name=select_5 >
<?php
foreach ($rows as $row)
{
echo "<option value='".$row->id."' >".$row->name."</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>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT id, name
FROM #__users ";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
<div class='form_item' >
<div class="form_element cf_dropdown" >
<label class='cf_label' >Sélectionner les plongeurs</label>
<select class="cf_inputbox validate-selection" id='select_6' multiple='multiple' size='4' name=select_6[] >
<?php
foreach ( $rows as $row )
{
echo "<option value='".$row->id."' >".$row->name."</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=Submit1 ></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_button" ><INPUT type=submit value=Submit2 ></DIV>
<DIV class=clear > </DIV></DIV>
<?php
break;
case 2:
?>
// show code for page 2 here
<input type='hidden' name='page' value='2' />
<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>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM ".$db->nameQuote('#__users')." a
INNER JOIN ".$db->nameQuote('#__comprofiler')." b
ON ( a.id = b.id )
WHERE ( b.cb_niveauencadrement != '' )
OR ( b.cb_niveauplongeur = 'Niveau 4' )";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
<SELECT class="cf_inputbox validate-selection" id=select_5 size=3 name=select_5 >
<?php
foreach ($rows as $row)
{
echo "<option value='".$row->id."' >".$row->name."</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>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT id, name
FROM #__users ";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
<div class='form_item' >
<div class="form_element cf_dropdown" >
<label class='cf_label' >Sélectionner les plongeurs</label>
<select class="cf_inputbox validate-selection" id='select_6' multiple='multiple' size='4' name=select_6[] >
<?php
foreach ( $rows as $row )
{
echo "<option value='".$row->id."' >".$row->name."</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=Submit1 ></DIV>
<DIV class=clear > </DIV></DIV>
<DIV class=form_item >
<DIV class="form_element cf_button" ><INPUT type=submit value=Submit2 ></DIV>
<DIV class=clear > </DIV></DIV>
<?php
break;
// repeat as needed
}
?>
On submit code before sending
<?php
JRequest::setVar('select_6', implode(", ", JRequest::getVar('select_6')));
?>
<?php
$page = JRequest::getInt('page', '0', 'post');
switch ($page) {
case 0:
echo "We've got a problem - this should never happen!!";
break;
case 1:
$post =& JRequest::get('post');
// process the first page
...
// redisplay the form
showform($post);
// supress the email and db preocessing
$error_found = true;
break;
// repeat as needed
case n:
// process last page and let continue to emails and db
break;
}
?>