Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Javascript RegEX edit dynamic selected options

Avatar of DMackallii
DMackallii asked on
JavaScriptJScriptjQuery
3 Comments1 Solution387 ViewsLast Modified:
Greeings All;

I have a script that dynamically appends all highlighted items in a select box to a  textarea, See code below.

What I'd like to have happen is to have the highlighted items in the select box appended to 2 separate textarea boxes (and have just the item enclosed in quotations appear in the 1st textarea box).

Results:

Highlighted item: "7934,Ms 7934" <7934@something.com>,

Textarea1                  Textarea2
7934,Ms 7934           "7934,Ms 7934" <7934@something.com>,

<html>

<script>
function Copyall()
  {
    var container = document.Pinebox
    var qube = container.dataadded

    var numofqubeions = qube.length
    var itemspicked = new Array

    var j = 0
    for (i=0; i<numofqubeions; i++)
    {
      if (qube[i].selected === true)
      {
        itemspicked[j] = qube[i].value
        j++
      }
    }

    itemspicked = itemspicked.join(" ")

    document.getElementById("MrSpock").innerHTML = itemspicked
}


</script>
<body>


<form method=POST name="Pinebox">

<select name="dataadded" id="dataadded" multiple onchange='Copyall()' rows="5" cols="45">
<option>"7934,Ms 7934" <7934@something.com>,</option>
<option>"7935,Ms 7935" <7935@somethingelse.com>,</option>
<option>"7936,Ms 7936" <7936@somethingelse.com>,</option>
<option>"7937,Ms 7937" <7937@somethinggood.com>,</option>
<option>"7938,Ms 7938" <7938@something.com>,</option>
</select><textarea name="MrSpock" id="MrSpock" rows="5" cols="45"></textarea>

</form><BR><BR
</body>
</html>


Your thoughts.......

´*•.¸(`*•.¸?¸.•*´)¸.•*´
?«´•°*42DoubleDDs*°•´»?
.¸.•*(¸.•*´?`*•.¸) *•.¸
ASKER CERTIFIED SOLUTION
Avatar of Samuel Liew
Samuel LiewFlag of Australia image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers