Forum Moderators: open

Message Too Old, No Replies

Getting button value w/multiple submit buttons triggered by JavaScript

How to retrieve the value of a specific button

         

justinlong

11:09 pm on Feb 20, 2005 (gmt 0)



I have a form with three buttons & a drop down box. My intention is to have selecting any button (or clicking on a form item) automatically trigger a submit. The buttons are, for example, "Archive," "Spam" and "Trash" while the drop down box is a category box (this is for a personal email management system designed to handle emails related to projects I am working on). What I want to do is have an "onclick" immediately call a submit routine, but the value of the buttons are not being passed (although interestingly enough the value of the dropdown box is being passed). Here is the script in part:

<!--
function Select() {
var obj = new Object;
obj = document.eb.elements;
len = obj.length;
for(var i=0; i<len; i++){
obj[i].checked = true;
}
}
function Unselect() {
var obj = new Object;
obj = document.eb.elements;
len = obj.length;
for(var i=0; i<len; i++){
obj[i].checked = false;
}
}

function ArchiveButton() {
document.eb.archive.value = "Archive";
document.eb.submit();
}
//-->
</script>
<table width=100% cellspacing=0 cellpadding=3 border=0>
<form name="eb" method="POST" action="index.php?">
<input name="a" type="hidden" value="eb">
<input name="form" type="hidden" value="eb">
<TR bgcolor=#C4C4FF >
<TD bgcolor=#C4C4FF align=left colspan=2>
<input type="button" name="archive" value="Archive" onClick="ArchiveButton()">
<SELECT name="categorize" onchange="window.document.eb.submit()">
<OPTION value="" SELECTED="selected">Select Category</OPTION>
<OPTION value="1108938067">News</OPTION>
<OPTION value="1108856006">Personal/Family</OPTION>
<OPTION value="1108938088">Project Communications</OPTION>
<OPTION value="1108938082">Query</OPTION>
<OPTION value="1108938074">Resource Announcement</OPTION>
<OPTION value="1108938059">System</OPTION>
</SELECT>
<BR>
<b>Select: </b><a href="#" onclick="Select()">All</a></td>

I need to be able to get to the value of the button via a PHP script (e.g. I am looking for $_POST['archive']=="Archive"). I have also tried using window.document.eb.submit in the archive button's onClick value.

Any help appreciated.

orion_rus

6:06 pm on Feb 22, 2005 (gmt 0)

10+ Year Member



u can add to a buttons
onclick="location.href=index.html?variable=value";
and get it in a php with $_GET['variable'] function
good luck to you

Bernard Marx

6:32 pm on Feb 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



but the value of the buttons are not being passed

Passed to what?