Javascript 如何在jquery函数中使用smarty变量{html}输出
我正在做一个小项目,获取一些存储在mysql中的html代码,使用smarty赋值,然后使用jquery将值赋值给html中的。到目前为止,我能够让它工作,但是jquery没有处理html代码 jqueryJavascript 如何在jquery函数中使用smarty变量{html}输出,javascript,jquery,smarty,Javascript,Jquery,Smarty,我正在做一个小项目,获取一些存储在mysql中的html代码,使用smarty赋值,然后使用jquery将值赋值给html中的。到目前为止,我能够让它工作,但是jquery没有处理html代码 jquery {literal} <script> function code(val){ var id = val; if (id == 'msg'){ $('#txt_codes').val('{/literal}{$eml_codes}{literal}');} } </sc
{literal}
<script>
function code(val){
var id = val;
if (id == 'msg'){
$('#txt_codes').val('{/literal}{$eml_codes}{literal}');}
}
</script>
{/literal}
{$eml_codes} // outputs fine in html but nothing in jquery. if i use regular text rather
than html codes it works.
//options
<select name="type" onchange="code(this.value)">
<option value"msg">MSG</option>
<option value"other">other</option>
</select>
//textarea
<textarea id="txt_codes"></textarea>
any idea on how i can pass actual html codes?
{literal}
功能代码(val){
var-id=val;
如果(id='msg'){
$('#txt_code').val('{/literal}{$eml_code}{literal}');}
}
{/literal}
{$eml_code}//在html中输出良好,但在jquery中没有输出。如果我使用常规文本而不是
比html代码更有效。
//选择权
味精
其他
//文本区
你知道如何传递真正的html代码吗?
必须将smarty代码放入javasript变量中
var eml_codes = {$eml_codes};
{literal}
function code(val){
var id = val;
if (id == 'msg'){
$('#txt_codes').val(eml_codes);}
{/literal}
对于您的项目,是否需要使用smarty标记,或者您只是想将mysql中的值分配给元素值?您好,我必须为项目使用smary标记。我不认为smarty是问题所在,因为它的输出很好,只是jquery没有传递html代码javascript/jquery是客户端语言。服务器语言(PHP或ASP)将从数据库获取值并将其发送到web页面。直接(在页面加载之前)或在页面加载之后。你是怎么做到的?你能展示你的服务器端代码吗?我知道所有这些,那部分工作正常。我没有把它包括在上面的问题中,因为那部分工作得很好。。如果你在html中使用{$eml_code},我会看到数据库中的所有html代码,但由于某种原因jquery没有传递它。不过jquery确实传递常规文本