If I'm pretty sure there is just one form on the page, can i do this?
var myForm = document.forms[0];
If I'm not sure about the form, is it safer to do this?
if (document.forms[0]) {
var myForm = document.forms[0];
// more code here........
}
Can I then get the elements array like this?
var myElements = myForm.elements ;
?????????????
<script type="text/javascript">
function openInNewWindow String(windowTe xt) {
window.open(win dowText, 'Show_Form_Subm ission_To_User' ,
'toolbar=yes,wi dth=200,height= 400,directories =no,status=yes, scrollbars=yes, resizable=yes,m enubar=yes');
docWindow.focus ();
return false;
}
function postFormSubmiss ionToNewWindow( ) {
var elementsArrayLe ngth = document.forms[0].length;
var whatIsBeingSubm itted = '<h1>You just wrote:</h1>';
for (i=0; i < elementsArrayLe ngth; i++) {
whatIsBeingSubm itted += document.forms[0].elements[i];
whatIsBeingSubm itted += '<hr>';
}
openInNewWindow String(whatIsBe ingSubmitted);
}
</script>
var myForm = document.forms[0];
If I'm not sure about the form, is it safer to do this?
if (document.forms[0]) {
var myForm = document.forms[0];
// more code here........
}
Can I then get the elements array like this?
var myElements = myForm.elements ;
?????????????
<script type="text/javascript">
function openInNewWindow String(windowTe xt) {
window.open(win dowText, 'Show_Form_Subm ission_To_User' ,
'toolbar=yes,wi dth=200,height= 400,directories =no,status=yes, scrollbars=yes, resizable=yes,m enubar=yes');
docWindow.focus ();
return false;
}
function postFormSubmiss ionToNewWindow( ) {
var elementsArrayLe ngth = document.forms[0].length;
var whatIsBeingSubm itted = '<h1>You just wrote:</h1>';
for (i=0; i < elementsArrayLe ngth; i++) {
whatIsBeingSubm itted += document.forms[0].elements[i];
whatIsBeingSubm itted += '<hr>';
}
openInNewWindow String(whatIsBe ingSubmitted);
}
</script>
Comment