ab,
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: aslam bajaria <[EMAIL PROTECTED]>
:
: I have a form which has to have more than one submit
: button.
:
: But, each submit button will have to have a different
: fuseaction.
:
: Also, for one of the submit buttons, a message box
: should appear if the user has not selected something
: from the drop down menu.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
i personally would recommend that you use as little javascript as possible
in your solution so it's accessibility isn't limited to js-enabled users.
for the multiple submits, simply name all the submits the same thing and
then give them different values. then, instead of different fuseactions,
use a general fuseaction and put all the various processing code in a
template and separate it with cfif's based on the submit button that was
clicked (it's value). the only spot where i would use javascript would be
to validate the form if a particular button was clicked. here's how the
form would look like:
<form
action="#cgi.script_name#?fuseaction=process"
method="post" onSubmit="return validateForm(this)">
<!-- all your form elements would go here -->
<input
type="submit"
name="submit"
value="Add"
onClick="checkSubmit(this.value)">
<input
type="submit"
name="submit"
value="Edit"
onClick="checkSubmit(this.value)">
<input
type="submit"
name="submit"
value="Delete"
onClick="checkSubmit(this.value)">
</form>
then, at the top of your cf template that has this form you'll need this:
<cfhtmlhead text="
<script language=""JavaScript"" type=""text/javascript"">
<!--
function validateForm(form)
{
if(submit_clicked == 'Delete')
{
if(!form.dropdown.selectedIndex)
{
alert('Please select an item from the dropdown menu.');
form.dropdown.focus();
return false;
}
}
return true;
}
var submit_clicked = '';
function checkSubmit(sVal)
{
submit_clicked = sVal;
}
// -->
</script>
">
just change 'Delete' in the line "if(submit_clicked == 'Delete')" to
whatever the name of the button will be that you need to check the dropdown
for.
now, you switch statement will need to check for the fuseaction "process".
when it sees this fuseaction it needs to include act_process where you'll do
something like this:
<!--- act_process --->
<cfparam name="form.submit" default="">
<cfswitch expression="#form.submit#">
<cfcase value="Add">
<!--- do the stuff you need to do if it's add --->
</cfcase>
<cfcase value="Edit">
<!--- do the stuff you need to do if it's edit --->
</cfcase>
<cfcase value="Delete">
<!--- do the stuff you need to do if it's delete --->
</cfcase>
<cfdefaultcase>
<cflocation url="#cgi.script_name#" addtoken="no">
</cfdefaultcase>
</cfswitch>
alternatively, if the processing code is rather long for each one of the
submit buttons then you could put it in separate files and use <cfinclude>
within the switch above instead of placing the actual logic within.
good luck,
.jeff
name://jeff.howden
game://web.development
http://www.evolt.org/
mailto:[EMAIL PROTECTED]
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.