Problem with SELECTED in a listbox

Results 1 to 2 of 2

Thread: Problem with SELECTED in a listbox

  1. #1
    Val C. Guest

    Default Problem with SELECTED in a listbox

    I have a dynamic listbox who is populated by the selection of values in an other listbox. Here is my problem:<BR><BR>How can I save all the values of the listbox in a database WITHOUT highlighting the rows? Once my litsbox is populated, I need to select all the row with the mouse before clicking on a save button. If not, nothing is saved. <BR><BR>In other words, I want all the rows of the dynamic listbox to be selected by themselves when I click on SAVE...and I need a Genius to help me with this one! :)<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Problem with SELECTED in a listbox

    No genius here but here is one way to do it.<BR><BR>When the submit button is selected call a JavaScript routine.<BR><BR>onClick = javascript:callMe();<BR><BR>//In this routine make the items selected.<BR>function checkTotalItems (strFormName, strFieldName, strFormDescription, strType) {<BR><BR> var intCurrentOptions = 0; //current list of options<BR> var intSelectedItems = 0; //selected items in list<BR> var bReturnValue = 0;<BR> <BR> // Get the current number of options<BR> intCurrentOptions = eval("document." + strFormName + "." + strFieldName + ".options.length;");<BR> <BR> // Loop through each item, getting a total count of items selected<BR> for (i=0; i &#060; intCurrentOptions; i++) { <BR> <BR> // Check to see if the item isn&#039t selected, if it isn&#039t select it<BR> if (eval ("document." + strFormName + "." + strFieldName + ".options[i].selected == false;")) {<BR> <BR> eval ("document." + strFormName + "." + strFieldName + ".options[i].selected = true;")<BR><BR> }<BR><BR> // Submit the form<BR> eval ("document.trialsByMonth.submit();");<BR>}<BR><BR> <BR>HTH<BR>Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts