Hello all,

Happy New Year,

Well I was hoping that I could leave this and come back to it in the new year and I would see my error. :( No luck.

This should be really simple all I want to do is load a mol file from a SQL database and give it to Jmol. I have had some very good help from Tim (see below) but I don't want to keep pestering him. My current code is as follows:

<tr><td>Structure:</td><td colspan="4">
<?php
echo '<script type="text/_javascript_">';
echo 'var mol=\'\';';
if ($data['molfile']){
   echo '
var mol=\'parma name="loadInline" value="' .
preg_replace("/\n|\r/", "|", $data['molfile']) .
'" />\';';
}
else {
echo 'var mol = \'\';';
}
echo 'document.write(mol);';
echo 'jmolInitialize("java/jmol");';
echo 'jmolApplet(300);';
echo 'jmolLoadInline(mol);';
echo '</script>';
?>
<br>


I did the document.write thing just to check the mol file is there correctly. It looks ok to me but ..... I get a jmol applet on my page but no molecule. Any help would be great.

Thank again guys,

Paul Benton
PS the page is http://metlin.scripps.edu/htdocs-new/metabo_info_cp.php?molid=6
Research Technician
Mass Spectrometry
   o The
  /
o Scripps
  \
   o Research
  /
o Institute 

Tim,

    Thanks for the explanation on the _javascript_, extension. I put the
code in and the mol file is now being read properly as one line.

that's good, yes?

just a thought, but if you want to simplify things, and since you're using php anyway, you could just eliminate the _javascript_ completely and do it all in php.


However, I wonder if there are too many lines in the mol file for Jmol?
I wouldn't think so; Jmol has been shown to handle huge files.  what makes you think so?


Also i wanted to test if the mol variable was getting passed to the
other scripts tag. So I put:
<script>
mol; # TO GET THE VARIABLE BACK

if I understand, you want to print the value of mol to the html page.  once you declare a variable in js, it is available to the rest of the page (html is top-down parsing) so as long as your script tags are in the right order, it should work.  but the above code itself won't show anything; try:

<script type="text/_javascript_>
document.write(mol);
</script>

the use of php is complicating matters, to be sure, but it should have no adverse effect as long as your embedded js code is clean.  I have used php to write js in various projects, and have not run into any scope or other problems. still, I usually do it as a last resort - I find it cumbersome to sort out multiple layers of quotes, escapes, etc.  I try to stick to php alone whenever possible.


best,

tim
--Timothy Driscoll                                em: [EMAIL PROTECTED]
Virginia Bioinformatics Institute               ph: 540-231-3007
Bioinformatics I: M-1                           im: molvisions
Washington St., Blacksburg, VA 24061







-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to