
Originally Posted by
laszlof
{foreach from=$productcustomfields item=customfield}
<input type="hidden" id="{$customfield.name}" value="{$customfield.value}" />
{/foreach}
<h4>Field Data:</h4><span id="customfieldsval"></span>
<script language="javascript">
{literal}
$(document).ready(function() {
var field1 = $('#customfield1').val();
var field2 = $('#customfield2').val();
$('#customfieldsval').html(customfield1 + "Some random text here" + customfield2);
});
{/literal}
</script>
Replace customfield1 and customfield2 with the actual field names.
Hi -
It doesn't seem to be getting the vars:
Code:
{foreach from=$productcustomfields item=customfield}
<div class="col2half">
<p><h4>{$customfield.name}:</h4> {$customfield.value}</p>
</div>
{/foreach}
<h4>Custom Field:</h4><span id="customfieldsval"></span>
<script language="javascript">
{literal}
$(document).ready(function() {
var field1 = $('#ANAME').val();
var field2 = $('#BNAME').val();
$('#customfieldsval').html("http://domain.com/index.php?name1=" + ANAME + "&name2=" + BNAME);
});
{/literal}
</script>
Does not return anything.
I tried using field1 and field2 as well:
Code:
{foreach from=$productcustomfields item=customfield}
<div class="col2half">
<p><h4>{$customfield.name}:</h4> {$customfield.value}</p>
</div>
{/foreach}
<h4>Custom Field:</h4><span id="customfieldsval"></span>
<script language="javascript">
{literal}
$(document).ready(function() {
var field1 = $('#ANAME').val();
var field2 = $('#BNAME').val();
$('#customfieldsval').html("http://domain.com/index.php?name1=" + field1 + "&name2=" + field2);
});
{/literal}
</script>
This returns the text portion of the string, but the vars return as undefined:
Code:
http://domain.com/index.php?name1=undefined&name2=undefined
I thought this might be because it is outside of the $productcustomfields section, but even if I include the code within the loop (repeating it after every other field) I get the same results.