Click to See Complete Forum and Search --> : using javascript in IFRAME


raghu123
06-11-2007, 09:29 PM
Object doesn't support this property

I get the following error in javascript function.
I use this page in an iframe.

On click of button i get the error from javascript function "Object doesn't support this property"

-------------












<HTML>
<TITLE>System Users</TITLE>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function fnDelete(){
if(confirm('Are you sure you want to delete the model type')){
alert("start submiting...");


document.forms[0].method="post";
//document.formUser.target = "_self";

//document.formUser.action = 'enginemodelsedit.jsp';
//alert(document.formUser.action);
//document.forms[0].submit();
document.forms["formUser"].action;
document.forms["formUser"].submit();
alert("start submiting...");

}else{
return;
}

}
//-->
</SCRIPT>
</head>
<BODY style="overflow:auto;font-family:Arial;">
<!-- <FORM ID='formUser' name="formUser"
ACTION='enginemodelsedit.jsp'
METHOD='POST'> -->

<FORM ID='formUser' name="formUser"

>

<INPUT type='hidden' NAME='hdnUser' VALUE=''>
<INPUT type='hidden' NAME='hdnUser2' VALUE=''>


<TABLE CELLSPACING=0 WIDTH=100% border="1" bordercolor="red">
<COL WIDTH=120px>
<COL>



<TR>
<TD>&nbsp;</TD>

<TD STYLE='text-align:right;'>
<!-- <INPUT type='button' VALUE='Add Model' onClick="javascript:alert('hi');"> -->

<INPUT TYPE='submit' NAME='submit' VALUE='Add Model' STYLE='width:80px;'>
<INPUT TYPE='submit' NAME='submit' VALUE='Delete Model Type' STYLE='width:125px;'>

<INPUT type='button' VALUE='Delete Model Type' onClick="javascript:alert('hi');fnDelete();"

<INPUT TYPE='submit' NAME='submit' VALUE='Add Model Type' STYLE='width:120px;'>
</TD>
</TR>


</TABLE>

</FORM>

</BODY>
</HTML>

ray326
06-11-2007, 10:25 PM
Well I think I'd use document.getElementById("formUser") to get a reference to the form.

raghu123
06-12-2007, 12:47 AM
after modifying as below also i get the same error

document.getElementById("formUser").method="post";
document.getElementById("formUser").action= 'enginemodelsedit.jsp';

document.getElementById("formUser").submit();

Tweak4
06-12-2007, 09:40 AM
Which button is causing problems?

<INPUT type='button' VALUE='Delete Model Type' onClick="javascript:alert('hi');fnDelete();"

1. Remove the "javascript:" from the event handler. Since this is a handler for a JS event, the assumption is that JS code will be run, so declaring it as JS is unnecessary and may cause additional problems.
2. Make sure your tags are formed properly. This one seems to be missing its final ">" (or possibly "/>", since you didn't specify a doctype)

Also, I can't say for sure, due to the omitted doctype, but chances are your html tags should all be in lowercase, rather than upper.

svidgen
06-21-2007, 05:44 PM
Well, there are a lot of things wrong with this code. But it looks like the main problem is the "submit" naming convention on your many submit buttons--don't do that. For your own sanity and the sake of stability, don't put methods and properties with the same name on objects: submit() and submit on userForm in this case.

Here's what I came up with:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
<head>

<TITLE>System Users</TITLE>

<SCRIPT type="text/javascript">
<!--

function fnDelete() {
if(confirm('Are you sure you want to delete the model type')) {

// tell the user a form is being submitted
alert("start submiting...");

// change submit method to POST
document.formUser.method="post";

// this line couldn't have been doing anything productive:
// document.formUser.action;

// submit the form
document.formUser.submit();


// don't put this alert here.
// if you're form is being submitted, it shouldn't run.
// stop trying to confuse your browser.
// alert("start submiting...");

} else {
// go back from whence you came!
return;
}

}

//-->
</SCRIPT>

</head>

<BODY style="overflow:auto;font-family:Arial;">

<FORM ID='fUser' name="formUser" action="#">

<INPUT type='hidden' NAME='hdnUser' VALUE='' />
<INPUT type='hidden' NAME='hdnUser2' VALUE='' />


<TABLE CELLSPACING="0" WIDTH="100%' border="1" bordercolor="red">


<TR>
<TD>&nbsp;</TD>

<TD STYLE='text-align:right;'>

<INPUT TYPE='button' NAME='submit' VALUE='Add Model' STYLE='width:80px;' />
<INPUT TYPE='button' NAME='submit' VALUE='Delete Model Type' STYLE='width:125px;' />
<INPUT type='button' VALUE='Delete Model Type' OnClick="fnDelete();" />
<INPUT TYPE='button' NAME='submit' VALUE='Add Model Type' STYLE='width:120px;' />

</TD>
</TR>


</TABLE>

</FORM>

</BODY>
</HTML>

Hope that helps.