Posting a Molfile in a Form
Molfiles can be submitted as HTML form data using ChemWriter. The technique involves four steps:
- Add a ChemWriter instance to the page and assign an id, e.g., 'chemwriter'.
- Add a hidden text field to the page and assign an id, e.g., 'text-display'.
- Add a submit button to the page with an onClick attribute set to a JavaScript function, e.g., 'transferMolfile()'.
- Implement the transferMolfile() function.
The transferMolfile() function might consist of:
function transferMolfile() {
var chemwriter = document.getElementById('chemwriter');
var display = document.getElementById('text-display');
display.value = chemwriter.getMolfile();
}
The transferMolfile() function will execute prior to form submission, enabling the inclusion of the molfile as part of an HTTP POST request.
