Closed Thread Icon

Topic awaiting preservation: return confirm before form submittal? Pages that link to <a href="https://ozoneasylum.com/backlink?for=8864" title="Pages that link to Topic awaiting preservation: return confirm before form submittal?" rel="nofollow" >Topic awaiting preservation: return confirm before form submittal?\

 
Author Thread
Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 09-23-2003 16:47

I have a form that inputs data into a "todo" list. If the user edits a record and sets it as "complete", I'd like to let them know that it can no longer be edited if "complete" has been selected from a list box. How can I find out what was selected (before submitting) and when the user clicks "submit" , a prompt confirms their selection of "complete" with the ability to cancel the submission? HELP!

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-23-2003 17:04

In the form tag:

onsubmit="return confirm('Are you sure you want to submit this form as complete? You will not be able to change it later.');"

Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 09-23-2003 17:34

Slime, thanks for the tip, but it still does not dynamically recognize that "complete" was selected. This seems to work:

function verify(){
if(document.forms[0].editstatus.value=="complete"){
return confirm("You will not be able to edit this record after setting it's status to 'complete'.\nWould you like to continue anyway?");
return false;
}else{
return true;
}
}

within the HEAD and:

onSubmit="return verify()"

within the FORM tag...

Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 09-23-2003 17:52

However, if I try to stck these validations within the function:

code:
function verify(){
if(document.forms[0].editclient.value==""){
alert("Please specify a client!");
return false;
}else{
return true;
}
if(document.forms[0].edittype.value==""){
alert("Please specify a type!\nThis will describe the nature of the task.");
return false;
}else{
return true;
}
if(document.forms[0].editdetail.value==""){
alert("Please specify the details of the task!");
return false;
}else{
return true;
}
if(document.forms[0].editstatus.value=="complete"){
return confirm("You will not be able to edit this record after setting it's status to 'complete'.\nWould you like to continue anyway?");
return false;
}else{
return true;
}
}



it only checks the first validation and ignores the others...any suggestions?

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-23-2003 20:30

Yes remove the "else { return true}" from all the if statements until the last one.



.:[ Never resist a perfect moment ]:.

Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 09-23-2003 20:57

DOH!! I see now! Thanks bitdamaged!

BTW, this is not very important, but what are the possibilities that I could dynamically insert an additional field based on the fact that the user has selected "completed"?

For example, dropdown has "pending", "in progress", and "complete". If a user selects "complete", a checkbox shows requesting whether the user would like to enter completion notes after submission? Feasible?

« BackwardsOnwards »

Show Forum Drop Down Menu