Topic: Simple question about document.submit (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=28401" title="Pages that link to Topic: Simple question about document.submit (Page 1 of 1)" rel="nofollow" >Topic: Simple question about document.submit <span class="small">(Page 1 of 1)</span>\

 
justin
Nervous Wreck (II) Inmate

From: Stockholm, Sweden
Insane since: Jan 2006

posted posted 09-07-2006 09:45

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

posted posted 09-07-2006 09:56

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

posted posted 09-07-2006 10:01

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

is working!

H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 09-09-2006 03:49

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

posted posted 09-09-2006 13:59

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

justin
Nervous Wreck (II) Inmate

From: Stockholm, Sweden
Insane since: Jan 2006

posted posted 09-10-2006 19:51

Thanks guys!

roberts
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Mar 2007

posted posted 03-17-2007 10:35

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