* IS THERE A WAY to use this javascript addContent function,
* Incorporate the utility of an ADD button
* But avoid using the packaging of FORMS?
While making use of a sample for addContent (located at http://www.randomsnippets.com/2008/04/14/how-to-dynamically-add-content-to-a-div-via-javascript/, I stumbled into a problem that I hope someone can help on.
We have a PHP/MySQL page that has to be modified to ADD rows for data entry when needed. I have abandoned the traditional DOM object methods of adding a single row, since in this case the addition would be a whole block of rows. I don't think I'm smart enough to do that...
Anyway, an idea hit me to make use of our MySQL dB and store the rows in there, and retrieve them using their method.
<script language="javascript">
function addContent(divName, content) {
document.getElementById(divName).innerHTML = content;
}
</script>
<form name="myForm">
Content to be added:
<textarea name="myContent"><?php echo $_value ?></textarea>
<input type="button" value="Add content" onClick="addContent('myDiv', document.myForm.myContent.value); setCookie('content', document.myForm.myContent.value, 7);">
</form>
<br><br>
Your content will be added dynamically below:
<div id="myDiv"></div>
Skipping an ultimate requirement that the content of the addition be invisible and inaccessible, I tried the above out. It works, but the variable ($_value) has form elements in it, including <TEXTAREA></TEXTAREA>. The close of the tag, interrupts the value and throws the remaining code to the page, not awaiting insertion by the Submit Button. Example: [url]http://www.facey.com/insert_content1.php[/url]
The Submit button successfully produces the part that stayed inside, but you see my problem.
IS THERE A WAY to use this javascript addContent function,
incorporate the utility of an ADD button
but avoid using the packaging of FORMS?
Thanks for any help!
Bryan
[EMAIL="bfox@facey.com">bfox@facey.com[/EMAIL]
p.s. The PHP is transparent. Direct inclusion of the HTML contained in the variable as the value of TEXTAREA produces the same result.
Software/Hardware used:
ASKED:
December 11, 2008 11:44 PM
UPDATED:
April 23, 2009 2:06 PM