Forum Moderators: open

Message Too Old, No Replies

Firefox document.submit has no properties

         

Scezic

12:47 am on Mar 11, 2005 (gmt 0)

10+ Year Member



Hi, I just started trying to figure out javascript and I'm having a problem with some code in Firefox. I'm trying to convert an existing vbscript/php page. The page contains a switch to edit, update, delete, and add to a database. I understand that it is difficult to pass a value from javascript back to php on the same page so I decided to make a function that uses hidden fields and submits the page so that php can get the new post variables to set the switch. Here is what I did to set Delete:

function DeleteEntry(ID)
{
var rtn = confirm("Are you sure you want to delete this record?");

if (rtn == true)
{

document.writeln("<form method='POST' id='delData' name='delData'>");
document.writeln("<input type='hidden' name='Mode' value='DELETE'>");
document.writeln("<input type='hidden' name='CollectionID' value=\"" + ID + "\">");
document.writeln("</form>");
window.document.delData.submit();
}
}

I need Mode and CollectionID to get repassed through post, which this does in IE but in Firefox JavaScript Console I get Error: window.document.delData has no properties. Any suggestions as to what is going on? Also I'm unclear about the escape quotes for value = ID. This does work to pass the value but the notation seems strange to me.

Thanks.

Bernard Marx

1:08 am on Mar 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



document.forms.delData?

If you want to send info to PHP, how about sending it via the URL.
No need to create a form, just:

window.location.href = www.example.com/blah.htm?Mode=nuts&CollectionID=bananas;

Scezic

3:34 am on Mar 11, 2005 (gmt 0)

10+ Year Member



Thanks for the reply.

I might not understand correctly but document.forms.delData.submit() gives the same error. The current page uses POST to get the information, and from what I understand I'd have to use GET to use the url method.

If I do something like this:
document.writeln("<form method='POST' id='delData' name='delData'> test");

a page with 'test' shows briefly then the page reloads and performs the delete correctly. So the form has no data using the hidden values I guess. Is there anything else I could try.