Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

JavaScript Fill Textarea from HTML Select not working with FireFox or Opera but does in IE6

//
// Fill textarea with keywords from HTML Select element
//

This code DOES work in I.E6 (on my machine (XP pro), but doesn't work in Firefox 2.0.0.4 or Opera 9.0.2

The idea is to be able to either type in the text area directly or choose from a list of saved words in the select box. When a new choice is made from the select, it automatically gets inserted into the text area.

With Firefox , when the page is first loaded, I can choose from the select control and it works until I type something in the text area, and then it stops working.

With Opera 9.02, the select control doesn't work at all.

IE6, works fine.

Any hints tips, appreciated, as I'm a novice with javascript / DOM programming.

I quite possibly am not using the most correct / efficient document.XXX calls here.


Mike

You can test it at http://mstramba.com/fb5.html

///////////////
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <style type="text/css">textarea {  height:200px; width:50%;}</style>

<script type="text/javascript">

function htmlData(selectValue,targetTextArea)
{
//   alert("select box changed to : '" + selectValue + "'");

   var txtNode=document.createTextNode(selectValue);
   var textArea=document.getElementById(targetTextArea);
   textArea.appendChild(txtNode);
}
</script>
</head>

<body>
 <form method="post">
 <select name="country" id="selbox" onchange="htmlData(this.value,'content')" />
   <option value="#">-Select-</option>
   <option value="SuperCaliFragilisticExpiAliDocius">SuperCaliFragilisticExpiAliDocius</option>
   <option value="Discombombulatively">Discombombulatively</option>
   <option value="I don't understand how this can be happening">I don't understand how this can be happening</option>
 </select>

 <textarea name="content" id="content">Type some text or choose words from the select control</textarea>

 <input type="submit" />
</form>
</body>
</html>

Babelfish translate

Ok, so maybe some of you might think that Babelfish's the best translator out there. I don't know about that , but I do know where my towel is ;)
So, boys and girls, here's the bookmarklet that allows to translate your current web-page using the babelfish translation engine.

javascript:location.href='http://babelfish.altavista.com/babelfish/tr?trurl='+encodeURIComponent(location.href)+'&lp=%s&btnTrUrl=Translate'


To make it useful, save it as a bookmark in FF (or as a new search engine in Opera) and give it a keyword/shortcut by editing the bookmark's properties in FF (or the search properties in Opera). Let's call him, say 'bf', that should do it.

Here are some examples:
bf en_fr
bf fr_en
bf en_ja


Enjoy!
G.R.

Opera Syncing using Svn

This batch file allows to run opera after checking out your web-based opera profile. When you terminate your opera session, the batch will commit the changes you made to your profile during the opera session.

 REM OperaSync.bat
 @echo off
 
 set PRG=Opera
 set TARGET=%APPDATA%/%PRG%/%PRG%/profile
 set EXEC=%PROGS%/%PRG%/%PRG%.exe
 set REPO=https://********.googlecode.com/svn/trunk/%PROG%Sync
 set USER=*************
 
 echo Checking out from %REPO% ...
 svn checkout %REPO% "%TARGET%" --username %USER%
 echo %PROG% running ...
 %EXEC%
 echo Commiting to %REPO% ...
 svn commit -m --force-log "%TARGET%"
 echo Done.
 
 @echo on


Here's the list of files that I update from a svn repo for my Opera profile
contacts.adr
files.txt
jscripts/
jscripts/deliciousmp3.js
notes.adr
opcacrt6.dat
opcert6.dat
opera6.adr
search.ini
sessions/
sessions/autosave.win
sessions/autosave.win.bak
speeddial.ini

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS