Click to See Complete Forum and Search --> : need count from split function


bradkenyon
04-24-2008, 02:04 PM
i need the count of words between each separator, which is a colon separating each value, i want the count of values so i can put it in a for loop, so i can use that as an index when i plug the values into the value element of a input type="text" box

this is the code i have now, but as you see, i have it set to go from index 0 to 3, starting at 0 is cool, but i want it to automatically detect how the ending index, which is 3 in this example.


<%
dim txt,a
txt="Mr. David Miller:Mr. Brad Morse:Mr. Jack Smith:Mr. Johnny Cash:"
a=Split(txt,":")

for t = 0 to 3
%>
<input type="text" name="absentee" value="<%=a(t)%>" size="30"><br>
<%
next
%>

thanks in advanced.

bradkenyon
04-24-2008, 02:31 PM
nvm, got it working.


<script type="text/javascript">
function addInput()
{
var x = document.getElementById("inputs");
x.innerHTML += "<input type=\"text\" name=\"absenteee\" size=\"30\"/><br>";
}
</script>
<h1>Faculty/Staff Absentees</h1>

<%
if (Request.Form("formaction") = "process") Then
'Response.Write(Request.Form("absentee"))

Dim mode,mode_a,i
mode=Request("absenteee")

mode_a=split(mode,",")

For i=LBound(mode_a) to UBound(mode_a)
'Response.Write Trim(mode_a(i) & ":")
Next

'dim txt,a
dim a
'txt="Mr. David Miller:Mr. Brad Morse:Mr. Jack Smith:Mr. Johnny Cash::Mr. Johnny Cash:Mr. Johnny Cash:Mr. Johnny Cash:Mr. Johnny Cash:Mr. Johnny Cash:Mr. Johnny Cash"
a=Split(mode,",")

for t = 0 to UBOUND(a)
%>
<input type="text" name="absentee" value="<%= a(t) %>">
<%
next

'For i=LBound(mode_a) to UBound(mode_a)
'Response.Write mode_a(i) + ":"
'Next

else %>
<form name="myvar" method="post" action="<%Request.ServerVariables("SCRIPT_NAME")%>">

<input type="hidden" name="formaction" value="process">
Date: <input type="text" name="date" size="30" value="<%=FormatDateTime(date(),vblongdate)%>">
<p>Fill in names here: <small><input type="button" value="+" onmousedown="addInput();" />(click for more fields)</small></p>

<%
for i = 1 to 5
Response.Write "<input type=""text"" name=""absenteee"" size=""30""><br>"
next
%>

<div id="inputs"></div>
</p>

<p><input type="Submit" value="Submit" name="Submit"></p>
</form>
<%
end if
%>