<script type="text/javascript">
function prepare_values()
{ldelim}
var flag= true;
var i=0;
var total_questions = new Array();
var total_answer = new Array();
while(flag)
{ldelim}
var questions = document.getElementById("question_div_"+i);
if (questions == null)
{ldelim}
flag=false;
alert("Value of flag = "+flag);
{rdelim}
var answer = document.getElementById("answer_div_"+i);
total_questions[i]=questions.firstChild.innerHTML;
if(answer.firstChild.attributes['type'].value == 'text')
{ldelim}
total_answer[i]=answer.firstChild.nodeValue;
{rdelim}
if(answer.firstChild.attributes['type'].value == 'textarea')
{ldelim}
total_answer[i]=answer.firstChild.nodeValue;
{rdelim}
if(answer.firstChild.attributes['type'].value == 'radio_div')
{ldelim}
var radio_button_parent = document.getElementById(answer.firstChild.id);
var oRadio = document.getElementsByName(radio_button_parent.firstChild.name);
for(var k = 0; k < oRadio.length; k++)
{ldelim}
if(oRadio[k].checked)
{ldelim}
var radio_button_value = document.getElementById(oRadio[k].id);
alert("From inside of ever = "+radio_button_value.nextSibling.innerHTML);
total_answer[i]=radio_button_value.nextSibling.innerHTML;
{rdelim}
{rdelim}
{rdelim}
i=i+1;
{rdelim}
alert("hello");
{rdelim}
</script>
上記はSMARTY
、ボタンをクリックするとテンプレート ファイルで実行される私の JS コードです。コードは正常に動作していますが、最後の 3 行目、つまり alert("Hello"); が実行されていません。の後のもの{redelim}
は無視されます。何をすべきか ?
firebug のコードは次のとおりです。
<script type="text/javascript">
function prepare_values()
{
var flag= true;
var i=0;
var total_questions = new Array();
var total_answer = new Array();
while(flag)
{
var questions = document.getElementById("question_div_"+i);
if (questions == null)
{
flag=false;
alert("Value of flag = "+flag);
}
var answer = document.getElementById("answer_div_"+i);
total_questions[i]=questions.firstChild.innerHTML;
if(answer.firstChild.attributes['type'].value == 'text')
{
total_answer[i]=answer.firstChild.nodeValue;
}
if(answer.firstChild.attributes['type'].value == 'textarea')
{
total_answer[i]=answer.firstChild.nodeValue;
}
if(answer.firstChild.attributes['type'].value == 'radio_div')
{
var radio_button_parent = document.getElementById(answer.firstChild.id);
var oRadio = document.getElementsByName(radio_button_parent.firstChild.name);
for(var k = 0; k < oRadio.length; k++)
{
if(oRadio[k].checked)
{
var radio_button_value = document.getElementById(oRadio[k].id);
alert("From inside of ever = "+radio_button_value.nextSibling.innerHTML);
total_answer[i]=radio_button_value.nextSibling.innerHTML;
}
}
}
i=i+1;
}
alert("hello");
}
</script>