私の MVC アプリケーションには、フォーム フィールドというボタンが含まれています。ユーザーがそのボタンをクリックするたびに、オプションとしてテキスト、チェックボックスなどを含むモーダルボックスにドロップダウンリストが表示されます。フォームフィールドとドロップダウンリストのコード:
<input type="button" id="FormField" name="Form Field" value="Form Field" style="width: 110px; height: 30px; background-color: #FFFFFF;" onclick="return FormField_onclick()" />
function FormField_onclick(box) {
dhtmlx.modalbox({
title: "Form Field Creation Tool",
text: "<div id='form_in_box'><div ><label>Type: <select id='Type' name='Type'><option>Text</option><option>Checkbox</option><option>Radio</option><option>DropDown</option><option>Listbox</option></select></label><br></div><div><span class='dhtmlx_button'><input type='submit' value='Select' style='width: 86px' onclick='Select_type(this)'></span><span class='dhtmlx_button'><input type='button' value='Cancel' onclick='close_file(this)' style='width:80px;'></span></label></div></div>",
width: "300px"
});
}
ユーザーがドロップダウンリストから特定のオプションを選択するたびに、たとえばユーザーがテキストオプションを選択して [選択] ボタンをクリックすると、テキストボックスがカーソル位置に挿入されます。選択ボタンのコード:
function Select_type(box) {
var tp = document.getElementById('Type');
switch (tp) {
case "text":
{
var editor = CKEDITOR.instances.message;
editor.insertHtml('<input type="text" id="tx" name="tx" style="width: 110px; height: 30px" />');
}
break;
case "Checkbox": { var editor = CKEDITOR.instances.message;
editor.insertHtml('<input type="checkbox" id="chk" name="chk" value="Checkbox" style="width: 110px; height: 30px" />');}
break;
case "Radio":
{
var editor = CKEDITOR.instances.message;
editor.insertHtml('<input "radio" id="rd" name="rd" value="radio" style="width: 110px; height: 30px" />');
}
break;
case "DropDown": alert("DropDown");
break;
case "Listbox": alert("Listbox");
break;
}
dhtmlx.modalbox.hide(box);
}
しかし、これは私にはうまくいきません。アラートも機能しません。また、ドロップダウンとリストを含める方法もわかりません