Bob, Thank you very much, at the moment I’ve opted for the simpler (for me to understand) method by adding the script tags and the quotes and the page now has the check box showing and working.
Steve From: Robert Hanson [mailto:hans...@stolaf.edu] Sent: 12 August 2015 05:36 To: jmol-users@lists.sourceforge.net Subject: Re: [Jmol-users] simple question from a novice eager to learn Stephen, you are almost there -- just one issue: On Tue, Aug 11, 2015 at 2:59 PM, Stephen Hillier <stephen.hill...@hutton.ac.uk<mailto:stephen.hill...@hutton.ac.uk>> wrote: $(document).ready(function() { Info = { width: 400, height: 400, debug: false, j2sPath: "j2s", color: "0xC0C0C0", disableJ2SLoadMonitor: true, disableInitialConsole: true, addSelectionOptions: true, serverURL: "http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php", use: "HTML5", readyFunction: null, script: "load $caffeine" } $("#mydiv").html(Jmol.getAppletHtml("jmolApplet0",Info)) }); Very nice -- the applet is being created after the page is loaded. This is the way to go. </script> </head> <body> <span id=mydiv></span> <a href="javascript:Jmol.script(jmolApplet0, 'spin on')">spin on</a> <a href="javascript:Jmol.script(jmolApplet0, 'spin off')">spin off</a> This next is JavaScript, so you need a <script> tag here Jmol.jmolCheckbox(jmolApplet0, "spin on", "spin off", "toggle spin") and </script> here. Note that you have not defined jmolApplet0 yet --- that happens after the page is loaded. Two options: 1) define in the header the name as the same as the string jmolApplet0 = "jmolApplet0" 2) just use "jmolApplet0" in quotes here. JSmol will convert it later: <script> Jmol.jmolCheckbox("jmolApplet0", "spin on", "spin off", "toggle spin") </script> </body> </html> You can avoid all script tags in the body if you want by using Jmol.setDocument(0) in your $(document).ready() method and building all the buttons there. So, for example: ... <head> ... $(document).ready(function() { ... $("#mydiv").html(Jmol.getAppletHtml("jmolApplet0",Info)) ... Jmol.setDocument(0); // tells Jmol object to just return HTML; doesn't use document.write var s = Jmol.jmolLink(jmolApplet0, "spin on", "spin on") + " " + Jmol.jmolLink(jmolApplet0, "spin off", "spin off") + " " + Jmol.jmolCheckbox(jmolApplet0, "spin on", "spin off", "toggle spin") $("#buttondiv").html(s) }); ... </head> <body> ... <span id=mydiv></span> <span id=buttondiv></span> Bob If you are not the intended recipient, you should not read, copy, disclose or rely on any information contained in this email, and we would ask you to contact the sender immediately and delete the email from your system. Although the James Hutton Institute has taken reasonable precautions to ensure no viruses are present in this email, neither the Institute nor the sender accepts any responsibility for any viruses, and it is your responsibility to scan the email and any attachments. The James Hutton Institute is a Scottish charitable company limited by guarantee. Registered in Scotland No. SC374831 Registered Office: The James Hutton Institute, Invergowrie Dundee DD2 5DA. Charity No. SC041796
------------------------------------------------------------------------------
_______________________________________________ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users