Clearing Old Diagrams onlick of a Button/Click

User 4616a6b00d

13-08-2014 04:30:27

Hi,


I am using Marvin Sketch Applet,


Below is my code :


<h:panelGrid style="width:100%">


 <center>


   <script type="text/javascript">


     var mrvData = document.getElementById("frmMarvinSketch:moleculeTxt").value;


     if(mrvData == null){


     mrvData = "";


     }


    msketch_name="MSketch";


     msketch_begin("../marvin/",800,400);


     msketch_param("mol",mrvData);


     msketch_end();


 </script>


   </center>


</h:panelGrid>


 


Can you please help me with the HTML script/command in clearing the Marvin Editor while drawing a new drawing.


 


Thanks


MK

ChemAxon 4fa3cf533c

13-08-2014 17:17:25

Hi there,


First, you'll need a reference to the applet. If you've defined a name for your applet then you can easily refer it by document.MSketch, like in your example. For more information about reference to the applet please visit this link.


Then if you've got your reference to the applet you can use methods on that. You can find a simple example here, where clicking on the load button will load up a caffeine. In your case you will have to use setMol(String) method, with null parameter to set an empty molecule on the canvas. 


I hope I could help, if you need any further assistance, do not hesitate to ask.


Regards,


Tamas Fazekas-Vigh