View Full Version : Adding text based on form input

10-27-2006, 05:00 AM
This is my first time trying to code something with JavaScript.

Basicly I have a form with a checkbox, if the user checks the box some extra html code is added to the page. I did some googling and reading on displaying text with JavaScript but I can't seem to get this working.


<body bgcolor="#000000" text="#FFFFFF">

<script type="text/javascript">
function checkResults (form) {
var checkVar = form.check1.value;
document.writeln("<div style=\"position:absolute; left:302; top:288;\"><a href=\"timeline.html#week1\"><img src=\"marker.jpg\" style=\"border:none;\"></a></div>");

<img src="map1_shrink2.jpg" alt="Main Map"><br>

Mark 1:<input type="checkbox" name="check1" onclick="checkResults(this.form)">


With that code, when I click the checkbox the page reloads and displays the extra html but nothing else is there and the page never finishes loading.

The ultimate goal of this page is a map. The user will be able to check different boxes which will add route overlays.

Can someone point out what's wrong with this code or point me into a better direction of doing this (other than server side languages)?

10-27-2006, 08:43 AM
Instead of using

document.writeln you could use

innerHtml property of choosen object you could find some more information about it at http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerhtml.asp