Hi Bob,
Thanks for replying! I feared you would say that, however I have no clue how I could make a button appear for every row of the CC table and link to a form. That's why I'm so stubbornly holding on to the Edit_Record option. I'm sorry for the inconvenience 😟
The goal of the form is to have users upload their receipts and enter some extra information. They have the option to change some of the fields. When they enter an amount value, we calculate the value in Euro using Javascript to read the fieldvalues Amount and Currency. This worked in the simple CF form, but is no longer called when using the Edit_record CF form.
This is the code in the CC form's body:
<?php
switch ($MyRow->Status) {
case 'Approved' :
$color = 'green';
break;
case 'Not Approved' :
$color = 'red';
break;
case 'Changed' :
$color = 'orange';
break;
default:
$color = 'white';
break;
}
$user=& JFactory::getUser();
$currentuser=$MyRow->cf_user_id;
$count;
if ($user->id == $currentuser)
{
$count=$count+1;
?>
<p class="blocknummer"><span class="bignumber"><?php echo 0, $count ?></span></p>
<table CELLSPACING="1" align="CENTER" BORDER="2" BORDERCOLOR=#ffcc00 RULES=NONE FRAME=BOX CELLPADDING="5">
<TH>Edit</TH>
<TH>Amount</TH>
<TH>Category</TH>
<TH>Date</TH>
<TH>Status</TH>
<TH>Comments</TH>
<TH>Currency</TH>
<TH>AmountEuro</TH>
<TH>Picture</TH>
<tbody>
<tr>
<td style="width": 10%;">{edit_record}</td>
<b><td>{Amount}</td></b>
<td><div>{Category}</div></td>
<td><div>{Date}</div></td>
<b><td><div style='color: <?php echo "$color"; ?>'>{Status}</div></td></b>
<td><div>{Comments}</div></td>
<td><div>{Currency}</div></td>
<td><div>{AmountEur}</div></td>
<td><img src="./images/Receipts/{Photo}" width="180" height="180" align="RIGHT" style="border: 0;" /> </td>
</tr>
</tbody>
</table>
<br>
<?php
}
else if($count==0)
{
echo "No Receipts found";
}
?>
The Edit_Record option refers to the ChangeData form which exists out of the following code:
<div class="form_item">
<div class="form_element cf_multiholder" style="margin-left:0px!important;">
<label class="cf_label" style="display: none;">Click Me to Edit</label>
<table cellspacing="0" cellpadding="0" width="55%" title="" class="multi_container">
<tbody width="100%">
<tr width="100%">
<td style="width: auto; vertical-align: middle; text-align: left;">
<div class="form_item">
<div class="form_element cf_heading">
<h1 class="cf_text">Required information</h1>
</div>
<div class="cfclear">Â </div>
</div>
</td>
<td style="width: auto; vertical-align: middle; text-align: left;">
<div class="form_item">
<div class="form_element cf_heading">
<h1 class="cf_text">Upload picture file</h1>
</div>
<div class="cfclear">Â </div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="cfclear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_multiholder" style="margin-left:0px!important;">
<label class="cf_label" style="display: none;">Click Me to Edit</label>
<table cellspacing="0" cellpadding="0" width="67%" title="" class="multi_container">
<tbody width="100%">
<tr width="100%">
<td style="width: auto; vertical-align: middle; text-align: left;">
<div class="form_item">
<div class="form_element cf_datetimepicker">
<label class="cf_label" style="width: 100px;">Date</label>
<input class="cf_datetime required" title="" size="12" id="Date" name="Date" type="text" />
</div>
<div class="cfclear">Â </div>
</div>
</td>
<td style="width: auto; vertical-align: middle; text-align: left;">
<div class="form_item">
<div class="form_element cf_fileupload">
<label class="cf_label" style="width: 100px;">Upload</label>
<input class="cf_fileinput cf_inputbox" title="" size="20" id="file_7" name="Photo" type="file" />
</div>
<div class="cfclear">Â </div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="cfclear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_multiholder" style="margin-left:0px!important;">
<label class="cf_label" style="display: none;">Click Me to Edit</label>
<table cellspacing="0" cellpadding="0" width="40%" title="" class="multi_container">
<tbody width="100%">
<tr width="100%">
<td style="width: auto; vertical-align: middle; text-align: left;">
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 100px;">Category</label>
<select class="cf_inputbox validate-selection" id="select_6" size="1" title="" name="Category">
<option value="">Choose Option</option>
<option value="Train">Train</option>
<option value="Taxi">Taxi</option>
<option value="Flight">Flight</option>
<option value="Parking">Parking</option>
<option value="Lunch">Lunch</option>
<option value="Drinks">Drinks</option>
</select>
</div>
<div class="cfclear">Â </div>
</div>
</td>
<td style="width: auto; vertical-align: middle; text-align: left;">
<div class="form_item">
<div class="form_element cf_button">
<input value="Submit" name="button_9" type="submit" onClick="CalculateCurr(this.form)" />
</div>
<div class="cfclear">Â </div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="cfclear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 100px;">Amount</label>
<input class="cf_inputbox required validate-number" maxlength="150" size="12" title="" id="text_3" name="Amount" type="text" onChange="CalculateCurr(this.form)"/>
</div>
<div class="cfclear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;">Currency</label>
<select class="cf_inputbox" id="select_0" size="1" title="" name="Currency" onChange="CalculateCurr(this.form)">
<option value="EUR">EUR</option>
<option value="USD">USD</option>
<option value="GBP">GBP</option>
<option value="RUB">RUB</option>
<option value="JPY">JPY</option>
<option value="INR">INR</option>
<option value="CNY">CNY</option>
</select>
</div>
<div class="cfclear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_heading">
<h1 class="cf_text">Additional information</h1>
</div>
<div class="cfclear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_textarea">
<label class="cf_label" style="width: 150px;">Specifieke comments</label>
<textarea class="cf_inputbox" rows="3" id="text_10" title="" cols="30" name="Comments"></textarea>
</div>
<div class="cfclear">Â </div>
</div>
<?php $status = Changed ?>
<input value=<?php echo "$status" ?> id="hidden_8" name="Status" type="hidden"
<input value="" id="hidden_1" name="Cf_id" type="hidden" />
<input value="" id="hidden_9" name="AmountEur" type="hidden" />
Which internally calls the fuction CalculateCurr() after clicking the submit button
<!--
function CalculateCurr(frm) {
var AmountEur = 5
// Get the currency
form_field = frm.elements[6]
Curr = form_field.value
// Get the amount
form_field = frm.elements[5]
Amount = parseInt(form_field.value)
if(Curr=="USD") {AmountEur=Amount/1.3239}
else if(Curr=="JPY") {AmountEur=Amount/111.261451}
else if(Curr=="RUB") {AmountEur=Amount/41.565414}
else if(Curr=="CNY") {AmountEur=Amount/8.8271181}
else if(Curr=="INR") {AmountEur=Amount*0.0164868948}
else if(Curr=="GBP") {AmountEur=Amount*0.848545058}
else {
AmountEur = Amount
}
I hope this covers what information you require?
Thanks again for the support!
Sincerely,
Daan