简体   繁体   中英

How to use single quotes inside single quotes

I am using the following script to insert this value '%.1VALUE' in single quotes. But I am unable to pass the value inside the single quotes. Anyone please help me regarding this.

   <td width="10px"><input type="radio" name="dis" value=""  onclick="javascript:Jmol.script(jmolApplet0,'load /ws/output/re_$file;set antialiasDisplay on;color translucent;spacefill off;wireframe off;backbone 0.05;color cpk;select $donor;label %n %r %a;select $hydpos;label %n %r %a;select $acceptor;label %n %r %a;select $donacc;center selected;color cpk;color bond dodgerblue;color label white;set labeloffset 10 0;set measurement on;set measurements 0.001;color measurements yellow;set measure angstroms;spacefill 0.4;wireframe 0.2;backbone off;move -150 50 20 300 0 0 0 0 1;color measurements [x3DFF00];set fontsize 20;$distance'%.1VALUE'; set fontsize 10;set echo top left;echo <sup>*</sup>Standard Deviation- $dpi;')" ></td> 

That value is default command within the applet.'%.1VALUE' is used to round off the measured value in the applet

Command Usage: measure (ARG9:A.NH2)(ASP7:A.OD2)'%.1VALUE';

Consider $distance=measure (ARG9:A.NH2)(ASP7:A.OD2)

If i give the same command in console box of the applet its working Perfect. When I pass the value through the script its not executing.

Thanks in Advance..

尝试构建字符串,如下所示:

<td><input type="radio" name="dis" value="" onclick="javascript:Jmol.script(jmolApplet0,'set fontsize 20; $distance' + %.1VALUE + ';')" ></td>

假设语法正确,则可以使用转义符“ \\”来“告诉”尚未使用字符串完成的JavaScript,并且此单引号应位于屏幕内。

<td><input type="radio" name="dis" value="" onclick="javascript:Jmol.script(jmolApplet0,'set fontsize 20;$distance\'%.1VALUE\';')" ></td>

In JavaScript, you can escape characters with \\ :

<td>
   <input type="radio" name="dis" value="" onclick="javascript:Jmol.script(jmolApplet0,'set fontsize 20;$distance\'%.1VALUE';\')" >
</td>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM