Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 10-12-2005, 01:32 AM Need help again
lizard dude's Avatar
Super Talker

Posts: 119
Location: France
Trades: 0
Hey here is my script again

Quote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Chat Room</title>
</head>
<script type="text/javascript">
document.write( "<div id='lyr' style:'position:absolute;top:90px;left:10px;width: 200px;height:10px;z-index:10;background-color:black'></DIV>")


function enter()
{
var str=document.forms.f.txt.value;
var obj=documen.getElementById("lyr");
obj.document.open()
obj.document.write(str)
obj.document.close()
}


</script>

<body>



</body>
</html>
but the problem is that it doesn't do anything on the browser.........neither on the preview from my html editor........
__________________
forum------->
Please login or register to view this content. Registration is FREE
, for people who wants to have a good time ;)
website------>
Please login or register to view this content. Registration is FREE
(might be in construction :D)
Hope you have a great time and that my post is helpfull ;)
lizard dude is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-12-2005, 11:13 AM
kline11's Avatar
SearchBliss Web Tools

Latest Blog Post:
Oracle Embraces the Cloud
Posts: 1,724
Name: John
Location: USA
Trades: 0
Try adding into the body tag, onLoad="enter()" like this:
<body onLoad="enter()">
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
Old 10-12-2005, 11:18 AM
Novice Talker

Posts: 13
Trades: 0
Of course, if displays nothing. You have no HTML code between the <body> and </body> tags. That's obvious.

What the problem looks like to me is that you have the document.write function that you have will not print anything since it is hanging in the <head> section without a function. Also, you have no real text between your <DIV></DIV> tags.

You need a javascript function wrapped around the your document.write method and you need to call that function with an event handler.

Try this in your HTML:
<body onLoad="DisplayDIV()">
</body>

In your Javascript, try:
function DisplayDivs() {
document.write( "<div id='lyr' style:'position:absolute;top:90px;left:10px;width: 200px;height:10px;z-index:10;background-color:black'></DIV>")
}

I tried it in my browser and it works
Bruce
brucec is offline
Reply With Quote
View Public Profile
 
Old 10-12-2005, 11:21 AM
Novice Talker

Posts: 13
Trades: 0
Quote:
Originally Posted by kline11
Try adding into the body tag, onLoad="enter()" like this:
<body onLoad="enter()">
kline, I tried this and it did not work, because the LYR ID is still not being recognized by the web browser since it is not being printed by the javascript. He still needs a function around the LYR id document.write method and call it with the Enter function.
brucec is offline
Reply With Quote
View Public Profile
 
Old 10-17-2005, 10:50 AM
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Why not just write it in regular HTML instead of having JS write it? What exactly are you trying to accomplish with this code? There is no form named "f" referenced in your "enter()" function, and no field named "txt".

BTW - style: should be style= in the document.write code, but why not write the css info in a STYLE tag and just write:

Code:
document.write( "<div id='lyr'></DIV>")
and in your HEAD have
Code:
<style type="text/css" media="screen"><!--
#lyr {
	position:absolute;
	top:90px;
	left:10px;
	width:200px;
	height:10px;
	z-index:10;
	background-color:black
}
--></style>

Last edited by funkdaddu; 10-17-2005 at 11:00 AM..
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 10-18-2005, 09:28 PM
lizard dude's Avatar
Super Talker

Posts: 119
Location: France
Trades: 0
I ma a total noob and i got this script from a book im reading....it's suppose to let the user write something in it and click on a button that will send the text to the layer .....
__________________
forum------->
Please login or register to view this content. Registration is FREE
, for people who wants to have a good time ;)
website------>
Please login or register to view this content. Registration is FREE
(might be in construction :D)
Hope you have a great time and that my post is helpfull ;)
lizard dude is offline
Reply With Quote
View Public Profile
 
Old 10-19-2005, 12:46 AM
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Ah, ok, then on that page you need to have a form, named "f" that has a text field, named "txt", with a button (or using the form's onsubmit function) that will run the command "enter()" .. something like this is much simpler if you just want to write text in a box to a DIV:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Chat Room</title>
</head>
<script type="text/javascript">
function writeIt() {
	document.getElementById("lyr").innerHTML = document.f.txt.value;
}
</script>

<body>
<div id='lyr' style="color:white;position:absolute;top:90px;left:10px;width: 200px;z-index:10;background-color:black"></DIV>
<form name="f" onsubmit="writeIt(); return false;">
	<input type="text" name="txt" value="Type something here">
	<input type="submit">
</form>

</body>
</html>
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 10-20-2005, 10:43 PM
lizard dude's Avatar
Super Talker

Posts: 119
Location: France
Trades: 0
Alright thanks a lot you helped me so much!
__________________
forum------->
Please login or register to view this content. Registration is FREE
, for people who wants to have a good time ;)
website------>
Please login or register to view this content. Registration is FREE
(might be in construction :D)
Hope you have a great time and that my post is helpfull ;)
lizard dude is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need help again
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.49534 seconds with 12 queries