我有一个html页面,它基于html画布中的动态选择用户输入来绘制多个几何图形。
<select id="mySelect" name="Geometrical Figures"><option>Triangle</option>
<select id="cood1" name="Coordinate1"><option>50</option>
<select id="cood2" name="Coordinate2"><option>50</option>
<select id="imgcolor" name="ImageColour"><option>Red</option>
<select id="linewidth" name="Linewidth"><option>5</option>
<button class="button" id="imagedraw" onclick="draw()">Draw Image</button>
现在,当我单击按钮时,我想在文本中显示所选的详细信息
范例文字
已经绘制了一个三角形,其起始坐标为(50,50),颜色为红色,线宽为10。
注意:仅应在单击按钮时显示该文本。
将以下内容添加到您的onClick
函数中。还创建一个具有id的元素details
(或任何您想要的元素,但需要与该函数中的第一个选择器相对应)
function onClick(){
...//your current code
document.getElementById("details").innerHTML = "A triangle has been drawn with starting coordinates ("+document.getElementById("cood1").value+","+document.getElementById("cood2").value+") , colour "+document.getElementById("imgcolor").value+", linewidth "+document.getElementById("linewidth").value+".";
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句