線のレッスンに戻る
<script language="JavaScript1.2">
<!--
	/*
	* Other parts required but not shown here:
	* In the HTML file, the form tag contains the following attribute:
	*
	*   onsubmit="set_stroke(); return false;"
	*
	* And the input type=button tag in the form contains the following attribute:
	*
	*  onclick="set_stroke()"
	*/
	/*
	* This function sets the stroke-dasharray property of the "grid"
	* SVG element according to the values entered in the form.
	*/
	function set_stroke ()
	{
		var svgobj;
		var svgstyle;
		var svgdoc = document.dasharray.getSVGDocument();
		var value
			= document.manipulate.dasharray1.value
			+' '+document.manipulate.dasharray2.value
			+' '+document.manipulate.dasharray3.value
			+' '+document.manipulate.dasharray4.value
			+' '+document.manipulate.dasharray5.value
			+' '+document.manipulate.dasharray6.value;
		// Check that there are no gaps in the fields.
		var i;
		for (i = 6;  i > 0;  i--)
		{
			if (document.manipulate.elements['dasharray'+i].value.search(/^¥s*$/) == -1)
				break;
		}
		if (i > 0)
		{
			for (i--;  i > 0;  i--)
			{
				if (document.manipulate.elements['dasharray'+i].value.search(/^¥s*$/) != -1)
				{
					alert ('Please do not leave any of the leftmost fields blank.');
					return;
				}
			}
		}
		svgobj = svgdoc.getElementById('grid');
		svgstyle = svgobj.getStyle();
		svgstyle.setProperty ("stroke-dasharray", value);
	}
// -->
</script>
線のレッスンに戻る