我当前的代码是这样的,但它不会保存语言onclick
<form onsubmit="return false, saveDefaultLanguage('language-picker','default_language');" id="language-picker" action="{$base_url}">
{foreach from=$set_optional_languages key=k item=v name="local"} <img src="{$base_url}resources/images/flags/{$v}.png" alt="{$v}" width="32" height="32" class="noborder" />
<input type="radio" id="lang_{$smarty.foreach.local.index}" name="default_language" class="forminput" value="{$v}" {if $smarty.const.LOCAL_LANGUAGE==$v}checked="checked" onclick="saveDefaultLanguage('language-picker','default_language');" {/if} />
<label for="lang_{$smarty.foreach.local.index}">{$set_installed_languages.$v}</label>
{if ($smarty.foreach.local.index+1)%5 == 0}
{/if}
{/foreach}
<div class="clear"></div>
<input type="submit" class="button" name="" value="##DEFAULT_LANG_03##" onsubmit="lang_{$smarty.foreach.local.index};" />
<div class="clear"></div>
</form>
我之前的工作代码但与jquery冲突是
<form name="language-picker" id="language-picker" action="{$base_url}" onsubmit="javascript:return false;">
{foreach from=$set_optional_languages key=k item=v name="local"} <img src="{$base_url}resources/images/flags/{$v}.png" alt="{$v}" width="32" height="32" class="noborder" />
<input type="radio" id="lang_{$smarty.foreach.local.index}" name="default_language" class="forminput" value="{$v}" {if $smarty.const.LOCAL_LANGUAGE==$v}checked="checked"{/if} onclick="javascript:saveDefaultLanguage('language-picker','default_language');" />
<label for="lang_{$smarty.foreach.local.index}">{$set_installed_languages.$v}</label>
{if ($smarty.foreach.local.index+1)%5 == 0}
{/if}
{/foreach}
<input type="button" class="button" name="" value="##DEFAULT_LANG_03##" onclick="javascript:saveDefaultLanguage('language-picker','default_language');" />
</form>
任何线索都将受到赞赏。
此致
Gvilla。
答案 0 :(得分:0)
我认为它没有保存语言onclick
,因为你把它放在了聪明的{if}
里面,可能你想做这样的事情:
{if $smarty.const.LOCAL_LANGUAGE==$v}
checked="checked"
{else}
onclick="saveDefaultLanguage('language-picker','default_language');"
{/if}
此外,您在上一个onsubmit
标记中使用了<input>
属性,但这仅在<form>
代码中有效。