Oops. Sorry I forgot the code. Here is the message again this time
with the code.
I've posted a couple of questions in the past few days and several of
you have given me some very good help that has put me in the right
direction. Now let me give you a little background on what I'm trying
to do. I'm working on learning javascript and the DOM and thought a
good project to do this would be to make a page that would create a
new div and put a jmol applet in it. Thanks to your help I am making
some progress on this. At this point I've got a menu that sends a
reference to a pdb file to a function which creates the new div and
starts the jmol applet. The code is below. I'm having two problems
with it. The first problem is how the jmol applet appears on the page
when I call this function. It is basically clearing the page so that
the only thing that shows is the applet. The original applet that was
there and the pulldown menu disappear. I tried using
newDiv.appendChild instead of newDiv.update but this didn't work at
all. If I comment out the jmolApplet(400... line then [object Object]
appears on the page below the pulldown menu (where I expect it). The
second problem is that when the new applet is added to the page no
molecule is loaded in it. The alert command just before the
jmolApplet line shows just what I expect it to show, but I still only
get a blank jmol applet. So if you have any suggestions to help me
get the rest of the way to where I'm trying to get I'd really
appreciate it.
<script src="./javascripts/Jmol.js" type="text/javascript"></script>
<script src="./javascripts/prototype.js" type="text/javascript"></
script>
<script src="./javascripts/scriptaculous.js" type="text/javascript"></
script>
<script type="text/javascript">
var jmolObject = Class.create();
jmolObject.prototype = {
initialize: function(molecule){
jmolInitialize("jmol");
var loadString = "\"load ../Jmol/jmol/models/" +
molecule + "\"";
alert(loadString);
jmolApplet(400, loadString);
}
};
var divInc = 0;
function newJmolDiv(molecule) {
var newDiv = document.createElement('div');
var jmolID = 'jmolDiv_' + (divInc++);
newDiv.id = jmolID;
document.body.appendChild(newDiv);
newDiv.update(new jmolObject(molecule));
}
function appletReady() {
var atomSetArray =
jmolGetPropertyAsArray("atomInfo","atomno<5");
alert (atomSetArray[0].info);
}
</script>
</head>
<body>
<script type="text/javascript">
jmolInitialize("jmol");
jmolApplet(500, "load ../Jmol/jmol/models/1bf3.pdb; javascript
appletReady();");
</script>
<form>
<select onchange="newJmolDiv(value);">
<option value="1bf3.pdb">1bf3.pdb</option>
<option value="1CA2.pdb">1CA2.pdb</option>
<option value="211hexane.smol">211hexane.smol</option>
<option value="benzene.smol">benzene.smol</option>
<option value="pentane.pdb">pentane.pdb</option>
</select>
</form>
<form>
<input type="button" onclick="appletReady()" value="load">
</form>
</body>
</html>
***********************************************
Jeff Hansen
Department of Chemistry and Biochemistry
DePauw University
602 S. College Ave.
Greencastle, IN 46135
[EMAIL PROTECTED]
***********************************************
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users