From: Arun K. S. <ar...@im...> - 2013-07-05 09:48:19
|
> Right, your problem is that you are mixing Jmol scripting with JavaScript. > On your page > > load @name > > is expecting a Jmol variable called "name" > > But you have defined name as a JavaScript variable. So what you need there > is this: > > <script language="javascript" type="text/javascript"> > jmolInitialize("jmol/"); > jmolApplet(300, "load <?php echo $str ?>.sdf"); > </script> > > provided there is no possibility of spaces in that file name, or > > <script language="javascript" type="text/javascript"> > jmolInitialize("jmol/"); > jmolApplet(300, ' load "<?php echo $str ?>.sdf" ' ); > </script> > > if there is. I think you could put it all together like this, actually: > > > <SCRIPT SRC="jmol/Jmol.js"></SCRIPT> > <script language="javascript" type="text/javascript"> > jmolInitialize("jmol/"); > jmolApplet(300, ' load "<?php echo $_GET['ligand']?>.sdf" ' ); > </script> > > > This code suffers a bit from the possibility of script injection, so you > might want to think about that. > > > > > > > On Fri, Jul 5, 2013 at 5:36 AM, Arun Kumar Somavarapu > <ar...@im...>wrote: > >> Dear Friends, >> >> I am trying to include jmol in php page, it is working fine with static >> structure name while loading a structure like below >> >> <script language="javascript" type="text/javascript"> >> jmolInitialize("jmol/"); >> jmolApplet(300, "load str.sdf"); >> </script> >> >> i am having a problem when i use a variable . i have code like below >> >> <?php >> $str = $_GET['ligand']; >> ?> >> <SCRIPT SRC="jmol/./Jmol.js"></SCRIPT> >> <script language="javascript" type="text/javascript"> >> var name = "<?php echo $str ?>.sdf"; >> jmolInitialize("jmol/"); >> jmolApplet(300, "load @name"); >> </script> >> >> this script will load jmol in page successfully but with out structure and >> with >> out any error. >> >> can any one direct me towards error or suggest me any other method for >> successfully running jmol with a variable. >> >> Thanking you. >> >> ______________________________________________________________________ >> सूक्ष्मजीव प्रौद्योगिकी संस्थान (वैज्ञानिक औद्योगिक अनुसंधान परिषद) >> Institute of Microbial Technology (A CONSTITUENT ESTABLISHMENT OF CSIR) >> सैक्टर 39 ए, चण्डीगढ़ / Sector 39-A, Chandigarh >> पिन कोड/PIN CODE :160036 >> दूरभाष/EPABX :0172 6665 201-202 >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by Windows: >> >> Build for Windows Store. >> >> http://p.sf.net/sfu/windows-dev2dev >> _______________________________________________ >> Jmol-users mailing list >> Jmo...@li... >> https://lists.sourceforge.net/lists/listinfo/jmol-users >> > > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > St. Olaf College > Northfield, MN > http://www.stolaf.edu/people/hansonr > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Windows: > > Build for Windows Store. > > http://p.sf.net/sfu/windows-dev2dev_______________________________________________ > Jmol-users mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-users > Hello Sir, Thank you very much. The code is working. I am very happy after two days working on it. i tried the snippet that you suggested jmolApplet(300, ' load "<?php echo $_GET['ligand']?>.sdf" ' ); but it fails in accessing file names with spaces in it. error: "file not found exception". is there a way to handle this. Thanking you. ______________________________________________________________________ सूक्ष्मजीव प्रौद्योगिकी संस्थान (वैज्ञानिक औद्योगिक अनुसंधान परिषद) Institute of Microbial Technology (A CONSTITUENT ESTABLISHMENT OF CSIR) सैक्टर 39 ए, चण्डीगढ़ / Sector 39-A, Chandigarh पिन कोड/PIN CODE :160036 दूरभाष/EPABX :0172 6665 201-202 |