I have some checkboxes corresponding to some id order:
<input type="checkbox" class="order_id_list" name="order_id_list[]" id="order_id_list" value="{$order.id_order}" />
That i would like to check when I insert the Trackid number:
<input type="text" name="weight_{$order.id_order}" id="weight_{$order.id_order}" size="7" value="{$order.weight}"/>
If it may help I have found the tutorial below but does not work in my case:
<SCRIPT TYPE="text/javascript">
function recupValeurElement(IdElement)
{
if (document.getElementById)
{
return document.getElementById(IdElement);
}
else if (document.all)
{
return document.all[IdElement];
}
}
function fctCocherCase(ObjNumber)
{
recupValeurElement("Checkbox" + ObjNumber).checked = true;
}
</SCRIPT>
<p><input type="text" name="Input1" id="Input1" value="" size="70" onclick="fctCocherCase(1);"></p>
<input TYPE=CHECKBOX UNCHECKED name="Checkbox1" id="Checkbox1" value="" type="CHECKBOX">
I am really struggling to achieve this unfortunately, any help would be hugely appreciated.
2
Answers
Here is the solution based on Amundria's script and this similar topic:
Smarty variables in JavaScript
Here are the modifications to make it work
Thank you again I very appreciate it
I have simplified the example so you can see how it works without the variables, I don’t know what "{$order.id_order}" is and if it actually works but this example does:
I gave the textbox a static id (always the same) and used a button to confirm the id you type in the text field instead of OnKeyUp (everytime you type a character) just for the sake of testing.
It should check the checkbox corresponding to the number you type in the text (1,2 or 3). If you understand how it works then you can easily replace the checkboxes IDs with variables in your loop.