[SOLVED] opt.appendTo($("#s1")).text(val) - further modifications within this line

[SOLVED] opt.appendTo($("#s1")).text(val) - further modifications within this line

  1.         opt.appendTo($("#s1")).text(val);
I wonder if this text(val) being a string of text variables extracted from an array could be replaced by a formula still in this line, or if the code needs to be exploded to separate chunks first.

What i want to do is take this string and do the following:

  1. chayn=text(val)
  2. cutted=chayn.split("|");
  3. singl=cutted.slice(0,1);
and it is this singl that would be appended as an option to #s1 field.

so i end up with something i already know to be not accepted by js, presumably for some formal reasons:

  1. opt.appendTo($("#s1")).((text(val).split("|")).slice(0,1));
which in human language means "instead of that chain, put only the first slice of it"

what's wrong with that? can this be told at a glance?

it appears i am trying to do something which the framework of js does not allow?