Need help

I have the following code:


// search return dropdown
$('.ous').live('click', function() {
    // get ou value from vbs sub addou and add to results dropdown
    addou();
    // get current selection
    var resultou1 = $('.ous option:selected').val();
    // apply formatting for use in textarea
    var resultou = '""' + resultou1 + '""\
\\r';
     // add to textarea for export to parent page
    $('#ouParent textarea').append(resultou);
    // remove current selection from dropdown
    $('.ous option:selected').remove();
});

// results dropdown
$('.newous').live('click', function() {
    // get current selection
    var selected = $('.newous option:selected').val();
    // remove selection from this dropdown and append back to search return dropdown
    $('.newous option:selected').remove().appendTo('.ous');
    // ****** start textarea removal *****//
    // get current data from textarea
    var getData = $('.oudata').val(); // may need to use text or valHooks instead of val (val strips carriage return characters)
    // apply formatting to match what is in the textarea
    var NewData = '""' + selected + '""\
';
    // find string in textarea and remove it
});

This is a form with 2 selects with the ability to move options from one select to the other, when added to the second select I format the selection and append it to a textarea for export to a parent page to be used for an application specific project.

Everything is working 100% but I am stuck on the following and need help:

  • Issue 1: When an option is removed from the second select I need to search the textarea and remove that specific string preserving the formatting of the other strings, it cannot have any blank lines.
  • Issue 2: I want to prevent duplicates to be moved from the first select to the second select. This can happen if an end user runs another search (vbscript) using the same criteria many times thus appending the same data. The form needs to allow many searches but with different criteria.

I have well documented my code so it is easier to follow. Any help is greatly appreciated!

Thanks,
Bob

Issue 1 no longer is an issue as I was going about it the wrong way. I removed that from the dropdown function and created an each loop in the function that sends the data back to the parent. Still trying to work out the duplicates pieceā€¦I am posting the code I used in the function in case it helps someone else out.


$(.newous').each(function() {
     var resultou = $(this).val();
     resultou = '""' + resultou + '""\
';
    $('.oudata').append(resultou);
});

This topic can be closed. After a nice lunch and time to clear my head I was able to get this completed.