Show words of array in a diff line

Hewlett-packard / Hp pavilion notebook pc
March 21, 2009 at 01:05:13
Specs: Windows XP, 1.5 GHz / 495 MB
I'm trying to show each word in an array on each line in vbscript.

I've tried:
dim ray(2)

for i=0 to 2
" & ray(i))

The code above works but I now need to get words in an array and show each word on a different line in a span block named answer3.

The answer I currently get is only "tools" from the "john" string..
The code I have is:

<script language="vbscript">
sub fred

dim joarsp
joarsp=split(john_val, " ")
answer2.innerHTML=joarsp(0)+cstr(" ")+joarsp(12)

for i=0 to 12
answer3.innerHTML=(joarsp(i) & "

end sub
<form name="alice">

The string john = <input type="text" size="60" name="john" value="this is a string for the purpose of playing with string coding tools">

<li><span id="answer2">this is the contents of the span block with id answer2</span>
<li><span id="answer3">this is the contents of the span block with id answer3</span>

<input type="button" value="GO" onClick="fred">


See More: Show words of array in a diff line

Report •

March 21, 2009 at 15:37:06
for ...
    answer3.innerHTML=(joarsp(i) & "")

If the code is as you've posted, then the above looks as though it would store and overwrite each element of joarsp with each iteration of i, so the final value of answer3 would be joarsp[12] or whatever element was the last to have a valid result.

You'd *probably* want answer3.innerHTML = answer3.innerHTML & joarsp(i) & "<br />"

However, that would store whatever value answer3 had prior to calling fred(), so you'd need to erase its value whenever you call the routine.

I'm not sure on the correct syntax of vbs though as I'm not used to it.


Report •
Related Solutions

Ask Question