[Javascript] selecting between multiple submit buttons

Tim Lewis twlewis at softhome.net
Wed Jul 25 09:55:30 CDT 2007


Joe, could you trigger the events from the buttons with something like this?


<html><head>
<script language=JavaScript>
<!--
function AddRecord(sData) {
var msg=alert("AddRecord was selected. The data is " + sData); }
function DeleteRecord(sData) { var msg=alert("DeleteRecord was selected.
The data is " + sData); }

//________________________________________________________________
-->
</script>
</head>
<body>
<form id=myform>
<input id=txtInputFile type=text size=40>

<input id=Add type=submit value=Add name=Add
onclick="AddRecord(txtInputFile.value)">
<input id=Delete type=submit value=Delete name=Delete
onclick="DeleteRecord(txtInputFile.value)">

</form>
</body>
</html>

Tim


> i have a form that uses multiple submit buttons: one to select from a
> dropdown list of menu options, one to add a new record or update an
> existing record depending on which is appropriate at the time, and one
> to delete an existing record.  i use the following as the trigger for
> onsubmit
>
>
>
> <script language=\"javascript\">
> 		//<![CDATA[
> 			window.onload=requiredFields;
>
> 			function requiredFields()
> 			{
> 				window.onsubmit=testValue;
>                         }
>
> // ... (other functions)
>
> 		//]]>
> 	</script>
>
>
>
> sadly, it doesn't know how to distinguish between which submit button
> is being selected.  the few variations i've played with have no good
> effect and i haven't found anything addressing multiple submit
> buttons.  the parameter names for the buttons are "delete_button",
> "replace_record" (for adding or updating individual records) and
> "select_datagroup".  what have i missed so far that will allow me to
> respond to a specific submit button's activation?  i'm very new to js
> so it'll be hard to offend me by "talking down" to me with
> descriptions of what should appear to be obvious to everyone else.
>
> thanks,
> joe
>
>
> since this is a gmail account, please verify the mailing list is
> included in the reply to addresses
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>





More information about the Javascript mailing list