Jump to content


Photo

This is probably really easy !


  • Please log in to reply
5 replies to this topic

#1 jaymc

jaymc
  • Members
  • PipPipPip
  • Advanced Member
  • 1,521 posts
  • LocationLiverpool

Posted 04 October 2006 - 11:59 PM

<INPUT TYPE = Button VALUE = "Click Me" OnClick = "document.write('Hello World')">

Pretty simple right?

Well, it works... but not the way I want it too!

When clicking, the javascript writes 'Hello World' to the document, but deletes all the content. So, in this example, the form button disapears

I want it to just write 'Hello World' underneath the form button for example

How can this be achieved

Thanks!
I would love to change the world, but they won't give me the source code

SEO Agency

#2 yonta

yonta
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 05 October 2006 - 01:22 AM

How about putting a div below the submit button, and google about javascript's getElementById and innerHTML?

Yes, this is really easy. Too easy to give you the full answer. Just google.
do it, do it right, do it right now

#3 ldsmike88

ldsmike88
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts
  • LocationFlorida

Posted 05 October 2006 - 02:19 AM

Instead of telling it to write it over the document, try giving it a spacific div tag to write it to. Try using something like this:


<INPUT TYPE = Button VALUE = "Click Me" OnClick = "document.getElementById('myDivID').write('Hello World')">
<div id = "myDivID">It will appear here.</div>

Tell me if it works.

#4 jaymc

jaymc
  • Members
  • PipPipPip
  • Advanced Member
  • 1,521 posts
  • LocationLiverpool

Posted 06 October 2006 - 12:14 AM

That did not work
I would love to change the world, but they won't give me the source code

SEO Agency

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 06 October 2006 - 01:20 PM

Nor can it... only the document DOM object has a .write method.  However, you can set its .innerHTML instead.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#6 yonta

yonta
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 07 October 2006 - 02:08 PM

So basically

<INPUT TYPE = Button VALUE = "Click Me" OnClick = "document.getElementById('myDivID').innerHTML='Hello World'">
<div id = "myDivID">It will appear here.</div>

do it, do it right, do it right now




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users