0

Hi everybody!
I am weak in javascript. Can anybody help me.
I need to make script which takes from one field string(numbers separated by space copied from excel) divide it by space into variables and insert into another fields on this page.

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by stbuchok
0
<textarea name="receiver1" id="receiver1"></textarea> <br>
<input type="text" name="receiver2" value="" />           <br>
<input type="text" name="receiver3" value="" />               <br>
<input type="text" name="receiver4" value="" />                   <br>
<input type="text" name="receiver5" value="" />   <br>
<input type="text" name="receiver6" value="" />           <br>
<input type="text" name="receiver7" value="" />               <br>
<input type="text" name="receiver8" value="" />                   <br>
<input type="text" name="receiver9" value="" />
<br>
<input type="text" name="donator" value="" size="80" /><br>

in the donator input field I enter such formatted string

1   1   2.3 5.9 27.14   12.213  14.927  16.284  18.998  21.712

and I need them to be inserted into above fields. Additionally numbers thirth and forth must be formatted as (2.3cmx5.9cm) and inserted into textarea. Not easy right?

<button onclick='distribute();'>DO</button>
<script type="text/javascript">
function distribute(){
var all=document.getElementsByName("donator");
var allvalues=all.value;
here I need to divide string by spaces into separate parts and insert them into fields above
}
</script>

Edited by Nick Evan: Fixed formatting

0
//this will give you an array of values that were split by spaces
var arrValues = all.split(' ');
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.