Topic: Simple question about document.submit Pages that link to <a href="https://ozoneasylum.com/backlink?for=28401" title="Pages that link to Topic: Simple question about document.submit" rel="nofollow" >Topic: Simple question about document.submit\

 
Author Thread
justin
Nervous Wreck (II) Inmate

From: Stockholm, Sweden
Insane since: Jan 2006

IP logged posted posted 09-07-2006 09:45 Edit Quote

Tearing my hair out here.

Being a php'er, what would be the correct syntax for a variable name of a form? I have a page that generates multiple forms, and they're all given an individual name (ex. myform_34) and each one has a button (delete). Whenever "delete" is clicked, a confirmation-box popup and if the user clicks "ok" the form is submitted.

I have however been unsuccessful in writing the correct syntax for the script:
function confirmErase( id ) {
input_box=confirm("Do you really want to delete?");
if (input_box==true) {
document.myform_+id+.submit();
}
return false;
}


This aint working. And I know it's where I try to put in the variable in the document.-line. Maybe this approach is wrong and it needs to go into a string first. I've tried most but I'm still crap.

All help is welcome.

_Mauro
Maniac (V) Inmate

From:
Insane since: Jul 2005

IP logged posted posted 09-07-2006 09:56 Edit Quote

You need to access a collection, like document.forms["myform_3489"] or document.getElementById("myform_3489")

justin
Nervous Wreck (II) Inmate

From: Stockholm, Sweden
Insane since: Jan 2006

IP logged posted posted 09-07-2006 10:01 Edit Quote

looks like:
document.getElementById("myform_"+id).submit();

is working!

H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

IP logged posted posted 09-09-2006 03:49 Edit Quote

You can use document.formName.submit , in IE at least - not sure if other browsers like this however. The way you mentioned is probably more browser friendly.

_Mauro
Maniac (V) Inmate

From:
Insane since: Jul 2005

IP logged posted posted 09-09-2006 13:59 Edit Quote

The way he chose is correct, dom and w3c wise. therefore compatible.

justin
Nervous Wreck (II) Inmate

From: Stockholm, Sweden
Insane since: Jan 2006

IP logged posted posted 09-10-2006 19:51 Edit Quote

Thanks guys!

roberts
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Mar 2007

IP logged posted posted 03-17-2007 10:35 Edit Quote

it is working fine with all browsers except opera.

you should try:

<a href="#" onclick="document.getElementById('results').innerHTML='';document.forms['form_to_submit'].submit();return false;">submit</a>

---------
software reviews

(Edited by roberts on 03-17-2007 10:38)



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu