User 4d36853ea2
04-07-2012 20:24:38
Hi!
I currently am creating an online homeowrk applet for chemistry students. The students are supposed to pick a question, and when the question is selected a mechanism is presented. Each mechanism consists of a maximum of 10 smaller marvinsketch windows that when selected, pop out and allow the student to edit the molecule inside. When the student hits the submit button each molecule needs to be saved as a .xml file and stored for later use.
So far, I have set it up so that when there is one molecule and a student hits submit their answer is saved as a .xml file. However, I do not know how to make this work with multiple molecule windows. I am using PHP and Javascript.
I've posted the main code snippet that pertains to this problem below.
If anyone has advice it would be greatly appreciated!
while( $row = mysql_fetch_array($result) ) {
$identifiers[$k] = $row['identifier'];
echo "<td align = center>";
echo"
<script type='text/javascript' SRC='marvin/marvin.js'></script>
<script type='text/javascript'>
<!--
msketch_name = 'MSketch';
msketch_begin('marvin', 200, 200);
msketch_param('detach', 'hide');
msketch_param('undetachByX', 'false');
msketch_param('menubar', 'false');
msketch_param('mol', ' " . $row['filepath']. "' );
msketch_param('autoscale', 'true');
msketch_param('legacy_lifecycle', 'false');
msketch_end();
//-->
</script>";
echo "</td>";
$k++;
if( $k < $_SESSION['numIDs'] )
{
echo "<td align= center><img src= marvin/mols-2D/Questions/rxnArrow.jpg alt = 'didn't work'></td>";
}
?>
<script type='text/javascript' SRC='marvin/marvin.js'></script>
<script language='JavaScript' src='marvin/js2java.js'></script>
<script type='text/javascript'>
<!--
function getMol(format) {
var s = null;
if(document.MSketch != null) {
s = document.MSketch.getMol(format);
} else {
alert('Cannot get molecule:\n'+'no JavaScript to Java communication in your browser.\n');
}
return s;
}
function sendMol() {
var m = getMol('mrv');
if(m != null) {
document.MolForm.mol.value = m;
document.MolForm.submit();
} else {
alert('No molecule to post.');
}
return;
}
//-->
</script>
<p>
</body>
<?php
}
?>
<form name="MolForm" method="post" action="index2.php" enctype = "text/xml">
<input type="" name='mol' value=""/>
</form>
<form name="controlform">
<input type="button" name="send" value="Send" onClick="sendMol()"/>
</form>
</p>