On 2005-06-24 (14:49) Samuel Flores wrote:
> > This is the page I'm working on:
> >
> > http://dev.molmovdb.org/cgi-bin/jmol.cgi?mid_=3Dva1a1tA-1f6uA
> >
> > The button I referred to is labeled 'Testing'.
>
>Well I tried making my own button using the code you sent and I think
>it should work but it doesn't.
>
>The 'jmolScript' function is behaving funkily. If I do:
>
><script> jmolScript("select *; color green; spacefill 2.0") </script>
>
>It doesn't do anything at all. If I precede the jmolscript with an =
>'alert' function then the alert window appears and immediately I see
>my molecule highlighted in green. If I put the 'alert' function AFTER
>the = jmolscript function then nothing happens. No alert window, no
>green highlighting.
>
hi Sam,
1. you should not use <script></script> tags in an onclick handler; it calls a
javascript by default.
2. also, where you do use them, try defining your script tags more completely:
<script type="text/javascript"></script>
3. finally, the Jmol.js functions write buttons to the html page. once
written, you can not update them without reloading the page. so if your var
resnum changes on the page, your button scripts will not work as you have them
written now.
instead, try writing a function in the head like this:
<script type="text/javascript">
// initialize resnum:
var resnum = 0;
function incrementResnum() {
// just increment the var resnum.
resnum++;
}
function mySendScript( spt ) {
// update spt with the new value of resnum here.
// this example looks in spt for #resnum
// and replaces it with the current value of resnum:
var my_mod_spt = spt.replace( '#resnum', resnum );
// now send the new spt to jmol:
jmolScript( my_mod_spt );
}
</script>
then your buttons can call mySendScript() and pass it a script like this:
<input type="button" name="button1" id="button1" value="My button"
onclick="mySendScript( 'select #resnum;color green;spacefill 2.0'
);incrementResnum();" />
in this case, incrementResnum() just adds one to the value of resnum after each
button click. just an example, of course.
hth,
tim
--
Timothy Driscoll
molvisions - see, grasp, learn.
<http://www.molvisions.com/>
usa:north carolina:raleigh
"Our true nationality is mankind." - H.G. Wells
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers