Это index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My designer!!</title>
</head>
<script type="text/javascript" src="javascript.js"></script>
<body>
<select id="choose_element">
<option>Drop-Down List</option>
<option>CheckBox</option>
<option>Button</option>
<option>Text Input</option>
<option> Radio Button</option>
<option> Multi-line Input</option>
</select>
<input type="submit" value="Create" name="create" onclick="create_control()" />
</body>
</html>
А это файл javascript.js
function mousedown(e)
{
e = e||window.event;
obj = e.srcElement||e.target;
}
function mousemove(e)
{
e = e||window.event;
if (obj) {
obj.style.left = e.clientX + document.body.scrollLeft;
obj.style.top = e.clientY + document.body.scrollTop;
return false;
}
}
function mouseup()
{
obj = null;
}
function create_control()
{
var temp=window.prompt('Введите имя создаваемого элемента','');
if((temp!='') && (temp!=null))
{
elem=document.getElementById("choose_element");
select_value=elem.selectedIndex;
switch (select_value)
{
case 0:
{
drop_down_list=document.createElement('select');
drop_down_list.setAttribute("name", temp);
document.body.appendChild(drop_down_list);
}
break;
case 1:
{
check_box= document.createElement('input');
check_box.setAttribute("type","checkbox");
check_box.setAttribute("name", temp);
document.body.appendChild(check_box);
}
break;
case 2:
{
button= document.createElement('input');
button.setAttribute("type", "submit");
button.setAttribute("name", temp);
button.setAttribute("style","position:absolute;");
document.body.appendChild(button);
}
break;
case 3:
{
edit = document.createElement('input');
edit.setAttribute("type", "text")
edit.setAttribute("name",temp);
document.body.appendChild(edit);
}
break;
case 4:
{
radio=document.createElement('input');
radio.setAttribute("type", "radio");
radio.setAttribute("name", temp);
document.body.appendChild(radio);
}
break;
case 5:
{
textarea=document.createElement('textarea');
textarea.setAttribute("name",temp);
document.body.appendChild(textarea);
}
}
}
}
document.onmousedown = mousedown;
document.onmousemove = mousemove;
document.onmouseup = mouseup;