phpScheduleIt
May 19, 2013, 06:34:42 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Drop down list option selected.  (Read 1053 times)
Azyrus
Newbie
*

Karma: 0
Posts: 28


« on: April 23, 2012, 12:10:24 AM »

I'm not even half decent at PHP, I'm sure this is simple to achieve but for anyone looking to add a drop down list instead of a text field to the reservation page the code is below.

Change the simple custom field code in reserve.template.php show below:

Code:
/**
* Print out the reservation summary or a box to add/edit one
* @param string $environment environment to edit
* @param string $type type of reservation
*/
function print_environment($environment, $type) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr class="tableBorder">
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="cellColor"><?=translate('Environment')?></td>
<td class="cellColor" style="text-align: left;">
<?
if ($type == RES_TYPE_ADD || $type == RES_TYPE_MODIFY)
echo '<input type="text" name="environment" class="textbox" value="' . $environment . '"/>';
else
echo (!empty($environment) ? $environment : '');
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
}

Change the above code to the below code and adjust the fields as necessary.

Code:
/**
* Print out the reservation summary or a box to add/edit one
* @param string $environment environment to edit
* @param string $type type of reservation
*/
function print_environment($environment, $type) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr class="tableBorder">
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="cellColor" style="width:50%;">Quote Outcome:</td>
<td class="cellColor" style="text-align:right;">
<?
if ($type == RES_TYPE_ADD || $type == RES_TYPE_MODIFY)
echo '<select name="environment" class="textbox" value="' . $environment . '"/>';
if ($environment == Outdoors)
echo "<option selected=selected>Outdoors</option>";
else
echo "<option>Outside</option>";

if ($environment == Indoors)
echo "<option selected=selected>Indoors</option>";
else
echo "<option>Indoors</option>";

if ($environment == Underground)
echo "<option selected=selected>Underground</option>";
else
echo "<option>Underground</option>";

echo '</select>';
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
}

As I said I'm not even decent at PHP and this was the first method I found to work, if anyone knows of a better method and I know there must be please share it Smiley

All credits to Nick and a big thanks to him.
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5403


WWW
« Reply #1 on: April 23, 2012, 01:08:52 PM »

Thanks for sharing!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!