>- see footer for list info -<
Get rid of your onSubmit event
Change your submit buttons from input type="Submit" to input
type="Button"
Have 1 onClick event for both buttons
 
Like ...
 
<form name="IncidentForm" ID="IncidentForm" action="WriteData.cfm"
method="post">
<INPUT TYPE="Hidden" NAME="RecordToGet" ID="RecordToGet" VALUE="">
<INPUT TYPE="Button" NAME="Delete" ID="Delete" VALUE="Delete this
victim" onClick="SubmitForm('Delete',#RecordToGet#)">
<INPUT TYPE="Button" NAME="Add" ID="Add" VALUE="Add another victim"
onClick="SubmitForm('Add')">
 
... with the JS function like ...

function SubmitForm(Action,PassedVar) {
    if(Action=="Delete") {
        Confirmation=confirm("Are you sure you want to delete this
victim?");
        if(Confirmation) {
            document.getElementById("RecordToGet").value=PassedVar;
 
document.getElementById("IncidentForm").action="ModifyDelete.cfm";
            document.getElementById("IncidentForm").submit();
        }
    }
    else if(Action=="Add") {
        document.getElementById("IncidentForm").submit();
    }
}
 
... your tags must have an ID attribute in it as well (eg.
ID="IncidentForm" not just NAME="IncidentForm") for the JS (above) to
work. They will not even be able to submit the form at all if JS is off
(but won't be able to delete something by accident either).



________________________________

        From: Paul Swingewood [mailto:[EMAIL PROTECTED] 
        Sent: 28 June 2006 11:58
        To: [email protected]
        Subject: Re: [CF-Dev] OT - JS
        
        

        >- see footer for list info -< 
        Thanks for all that .... 

        I know have the function as .... 

        function confirm_entry(passedvar) 
                { 
                        input_box=confirm("Are you sure you want to
delete this victim?"); 
                        if (input_box==true) 
                                { 
                                        // submit the form to the delete
page 
                                        alert (passedvar); 
        
document.IncidentForm.action='ModifyDelete.cfm'; 
                                } 
                        else 
                                { 
                                        // Output when Cancel is clicked

                                        alert ("You clicked cancel"); 
                                } 
                } 
        //--> 
        </script> 

        <form name="IncidentForm" action="WriteData.cfm" method="post" 
        onSubmit="submitForm();"> 
                                                <input type="hidden"
name="FormNumber" value="4"> 
                <table border="0" width=95%> 
                        <tr> 
                                <td valign="top"
colspan="4"><b><cfoutput>#session.user# - 
        #Session.DFESNo#</cfoutput></b></td> 
                        </tr> 
                        <tr> 

        Blah Blah Blah 


        <tr> 
                                <td align="left"> 
                                        <input type="submit"
name="btnAddVictim" value="Add another victim" 
        onClick="this.form.action='WriteData.cfm?rpt=1';"> 
                                </td> 
                                <cfif #NumberOfVictims# GT 1> 
                                <td align="center"> 
                                        <cfoutput> 
                                        <input type="submit"
name="btnDeleteVictim" value="Delete this victim" 
        onclick="confirm_entry(#RecordToGet#);"> 
                                        </cfoutput> 
                                </td> 
                                </cfif> 
                                <!--- If there are no more records in
the list then don't show the next 
        victim button ---> 
                                        <cfif URL.ElementToGet LT
ListLen(VictimIdList)> 
                                <td align="right"> 

                                                <!--- if there are then
increment the elementtoget ---> 
                                                <cfset ElementToGet =
URL.ElementToGet + 1> 
                                                <cfoutput> 
                                                <input type="submit"
name="btnNextVictim" value="Next victim" 
        
onClick="this.form.action='ModifyData.cfm?rpt=1&ElementToGet=#ElementToG
et#&record=#RecordToGet#';"> 
                                                </cfoutput> 
                                </td> 
                                </cfif> 
                                <td align="right"> 
                                        <cfoutput> 
                                        <input type="submit"
name="btnNextForm" value="Next" 
        
onClick="this.form.action='ModifyData.cfm?record=#RecordToGet#';"> 
                                        </cfoutput> 
                                </td> 
                        </tr> 
                </table> 

        </form> 



        A couple of things .... 

        How do I set the hidden field in the function. Do I have to
define something 
        in the form first? Im not sure of the syntax to refer to a field
form in JS. 

        Also how do I make the cancel do nothing (Return to the page) at
present it 
        submits the form with its default action ..... 


        Regards - Paul

_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- Hosting provided by www.cfmxhosting.co.uk -<
>- Forum provided by www.fusetalk.com -<
>- DHTML Menus provided by www.APYCOM.com -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to