Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-27-2006, 04:00 AM   PM User | #1
PureMisery
New Coder

 
Join Date: Dec 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
PureMisery is an unknown quantity at this point
Adding text based on form input

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.

Code:
<html>
<head>
<title>Test</title>
</head>

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

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

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

<FORM NAME="myform" ACTION="" METHOD="GET">
Mark 1:<input type="checkbox" name="check1" onclick="checkResults(this.form)">
</FORM>

</body>
</html>
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)?
PureMisery is offline   Reply With Quote
Old 10-27-2006, 07:43 AM   PM User | #2
gunman
New Coder

 
Join Date: Jul 2005
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
gunman is an unknown quantity at this point
Instead of using
Quote:
document.writeln
you could use
Quote:
innerHtml
property of choosen object you could find some more information about it at http://msdn.microsoft.com/workshop/a.../innerhtml.asp
__________________
If you can not find a decision, maybe you have to try to change a problem

http://www.gunman.co.nr
http://bglinux.org
gunman is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:36 PM.


Advertisement
Log in to turn off these ads.