Link to home
Start Free TrialLog in
Avatar of DMackallii
DMackallii

asked on

Javascript RegEX edit dynamic selected options

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>

Open in new window



Your thoughts.......

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

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DMackallii
DMackallii

ASKER

That is EXACTLY what I'm looking sam2912!

Thank you soooo much.

You sir walk with BIG BRASS ONES! (unless Sam is short for Samantha)

Thanks again.

´*•.¸(`*•.¸?¸.•*´)¸.•*´
?«´•°*42DoubleDDs*°•´»?
.¸.•*(¸.•*´?`*•.¸) *•.¸
Thanks for the points. It is very encouraging to hear that my solution has helped solve your problem.

Kind Regards