image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Design & Media

Reply
 
Thread Tools
  #1  
Old January 5th, 2005, 02:11 PM
andehlu's Avatar
this modern love
 
Join Date: Feb 2004
Location: torontoCANADA
Posts: 244
Thanks: 0
Thanked 0 Times in 0 Posts
andehlu is on a distinguished road
javascript issue (how have i never had this problem before?)

Hey all,
I find it completely bizarre how I have never came across this problem yet. What I am trying to do is change text dynamically with Javascript. I want to make a Javascript function that changes some (without being in a form element). the text right now is IN a div, so maybe I can work it like that?
Thanks for your help...
__________________
site | blog | garageband experiments
Reply With Quote
  #2  
Old January 5th, 2005, 08:50 PM
Partially Insane
 
Join Date: Oct 2001
Location: Buenos Aires, Argentina
Posts: 117
Thanks: 0
Thanked 0 Times in 0 Posts
agusgriego is on a distinguished road
Here's the solution

<div id="mydiv">
text that will change
</div>

<script language="javascript">
function changetext(newtext){
document.getElementById('mydiv').innerHTML = newtext
}
</script>


You have the div with it's own id and the function that changes the text. now you only have to use that function applied in a button, a link, etc. passing the new text as a parameter.
hope it helps.
Reply With Quote
  #3  
Old January 6th, 2005, 09:08 AM
andehlu's Avatar
this modern love
 
Join Date: Feb 2004
Location: torontoCANADA
Posts: 244
Thanks: 0
Thanked 0 Times in 0 Posts
andehlu is on a distinguished road
perfect thanks alot, Im sure this is cool across most nbrowsers, right? Ive never seen 'innerHTML' before.
__________________
site | blog | garageband experiments
Reply With Quote
  #4  
Old January 6th, 2005, 09:39 PM
Partially Insane
 
Join Date: Oct 2001
Location: Buenos Aires, Argentina
Posts: 117
Thanks: 0
Thanked 0 Times in 0 Posts
agusgriego is on a distinguished road
yes, it works with browsers version 5 and up
Reply With Quote
Reply

Thread Tools

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
Forum Jump


All times are GMT -5. The time now is 05:37 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.