I would like to implement the script http://www.chronoengine.com/faqs/70-cfv5/5251-how-can-i-build-a-product-list.html inserting a dropdown for selecting a format linked to the price. I tried using the following code
js.code
thanks for the reply
<?php
foreach ( $form->data['products'] as $p ) {
$path_foto= JURI::root(). $p['allegato'];
echo "<tr>
<td>{$p['cf_id']}</td>
<td>{$p['p_name']}</td>
<td><img src='".$path_foto ."' width='100' height='100'/></td>
<td>{$p['p_description']}</td>
<td>P<input type='text' name='prezzo[{$p['cf_id']}]' id='prezzo'/></td>
<td>Q<input type='text' name='quantity[{$p['cf_id']}]' id='quantity_{$p['cf_id']} size='4' value='1'/></td>
<td>";
?>
<?php
echo "{$p['cf_id']}";
echo "<select name='formato' id='formato' onchange='formatoFunz()'>";
$db =& JFactory::getDBO();
$query = "SELECT `formato` AS formato,`prezzo` AS prezzo FROM `bqu1s_cf_prodotti_formati`";
$db->setQuery($query);
$formato = $db->loadObjectList();
foreach($formato as $o)
{
$data = $o->formato;
$data2 = $o->prezzo;
echo "<option value=".$data2.">".$data."</option>";
}
echo "</select></td></tr>";
}
?>
but the change field price is only in the first record. I think I'll have to tie the selection idem record but still can not.
js.code
function formatoFunz() {
var x = document.getElementById("formato").value;
document.getElementById("prezzo").value = x;
}
thanks for the reply