tsturgeon
Posts: 7
|
| Posted: 05/17/2006, 10:50 AM |
|
I want to add a button to a Record form that contains a multi-select ListBox.
When the button is pressed, I want to select all the items in the list, or deselect all.
Right now, when I add a button, it activates the submit button even if I give it the Cancel function.
How do I get the button to fire the proper event without submitting the form?
Also, how do I set the items as SELECTED using selected?
|
 |
 |
Benjamin Krajmalnik
|
| Posted: 05/17/2006, 12:26 PM |
|
Use a regulat HTML button (not a CodeCharge button). Capture the onClick()
event to call a Javascript function which will select the items.
I have something similar, except I am using a checkbox as the toggler, and a
checkbox list instead.
The function looks like this:
function select_deselectAll (chkVal, idVal)
{
var frm = document.forms.tblRepsSearch;
var elementcount;
elementcount = frm.length;
// Loop through all elements
for (i=0; i<elementcount; i++)
{
if (frm.elements.type=='checkbox')
{
// Check if main checkbox is checked
if(chkVal == true)
{
frm.elements.checked = true;
}
else
{
frm.elements.checked = false;
}
}
}
}
and is called by a control in a form called tblRepsSearch as follows:
<span style="FLOAT: left; "><input type="checkbox" name="{CheckAll_Name}"
value="1" onclick="javascript: return select_deselectAll (this.checked,
this.id);" {CheckAll}> All</span>
Hope this helps you out.
|
|
|
 |
|