Skip to content Skip to sidebar Skip to footer

Transfer Data From Javascript Popup Multiline Textbox To A Select Control

I am trying to transfer data from a multiline textbox to a select control. The multiline textbox appears as a popup and I want all the records pasted in the textbox to be transfer

Solution 1:

You could serialize the contents of the textarea and then do what you need to do with it (Post it to a controller or perhaps hand it off to the underlying page somewhere)

$('form').submit(function(e){
   e.preventDefault();
   e.stopPropagation();

   var o = {};
   $( $('textarea').val().split(/\n|\r/) ).each(function(i){
      o[i] = this;
    });   
    var jsonString = JSON.stringify(o);   

    // DO SOMETHING WITH JSON OBJECT HERE
});​

http://jsfiddle.net/vUH3a/

Solution 2:

This will give you a start.

$("Button Selector").click(function(){
varSelectOptions= [];
        $("list Selector").each(function () {
            SelectOptions.push($(this).attr('id'));
        });
SelectOptions.each(function () {
            //build your mark up here and return
        });
});

Post a Comment for "Transfer Data From Javascript Popup Multiline Textbox To A Select Control"