document.forms[0].submit() not working.

Discussion in 'JavaScript' started by tejahere, Oct 14, 2007.

  1. #1
    Hi ,
    Pls look into the below function thru which i am calling a modal dialog. After the dialog returned true I am calling document.forms[0].submit();But I am getting an error. object expected. Pls help me out . The function is given below.

    function fnOpen(targetPage)
    {
    myObject.value = "emp1";
    alert(myObject.value);
    var returnstring = showModalDialog('child.jsp', myObject, "dialogHeight:30px; dialogWidth:400px; scroll:no; status:no; unadorned:no; resizable:no; edge:raised; dialogLeft:middle; dialogTop:middle; center:Yes");
    alert(returnstring);
    if(returnstring)
    {
    document.forms[0].action="/testworkspace-ViewController-context-
    root/testservlet";
    document.forms[0].submit();
    }
    }

    <input type="button" name="submit" id="deleteenable" value="DELETE" onclick="fnOpen('child.jsp');" >
     
    tejahere, Oct 14, 2007 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Is the above input actually enclosed within a form, or is it just as shown?
     
    Logic Ali, Oct 14, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Give the submit button another "name". It's conflicting with the submit() function name. Or remove the name...

    
    <input type="button" id="deleteenable" value="DELETE" onclick="fnOpen('child.jsp');" >
    
    HTML:
     
    nico_swd, Oct 14, 2007 IP