shang_lan
asked on
Populate data into form
I am trying to populate data of an array into text boxes. I have the following code:
for i = 0 to UBound(array,2)
response.write "<input type=""text"" name=""EmployeeName"" value="&array(0,i)&"><br>"
next
However, the resulting text boxes only show the first name of the employee, ignoring the rest, i.e. the last name and the space in between. Any suggestions?
for i = 0 to UBound(array,2)
response.write "<input type=""text"" name=""EmployeeName"" value="&array(0,i)&"><br>"
next
However, the resulting text boxes only show the first name of the employee, ignoring the rest, i.e. the last name and the space in between. Any suggestions?
Or perhaps to avoid confusion with the number of " characters use ' instead:
for i = 0 to UBound(array,2)
response.write "<input type='text' name='EmployeeName' value='"&array(0,i)&"'><br >"
next
for i = 0 to UBound(array,2)
response.write "<input type='text' name='EmployeeName' value='"&array(0,i)&"'><br
next
Here's what I got working in VB with a Textbox called Text1 and a command button called Command1 (the defaults).
You've got to use the Chr(34) in place of the " characters, because VB interprets those as the end of the sting instead.
Private Sub Command1_Click()
Dim strArray(0 To 4, 1 To 2) As String
Dim i As Integer
strArray(0, 1) = "Mantle"
strArray(0, 2) = "Mickey"
strArray(1, 1) = "Mouse"
strArray(1, 2) = "Mickey"
strArray(2, 1) = "Mouse"
strArray(2, 2) = "Mighty"
strArray(3, 1) = "Casey"
strArray(3, 2) = "Mickey"
strArray(4, 1) = "Mouse"
strArray(4, 2) = "Sean"
For i = 0 To UBound(strArray)
With Text1
.Text = .Text & "<input type=" & Chr(34) & Chr(34) & _
"text" & Chr(34) & Chr(34) & " name=" & Chr(34) & Chr(34) & _
"EmployeeName" & Chr(34) & Chr(34) & _
" value=" & strArray(i, 1) & "><br>"
.Text = .Text & "<input type=" & Chr(34) & Chr(34) & _
"text" & Chr(34) & Chr(34) & " name=" & Chr(34) & Chr(34) & _
"EmployeeName" & Chr(34) & Chr(34) & _
" value=" & strArray(i, 2) & "><br>" & vbCrLf
End With
Next
End Sub
You've got to use the Chr(34) in place of the " characters, because VB interprets those as the end of the sting instead.
Private Sub Command1_Click()
Dim strArray(0 To 4, 1 To 2) As String
Dim i As Integer
strArray(0, 1) = "Mantle"
strArray(0, 2) = "Mickey"
strArray(1, 1) = "Mouse"
strArray(1, 2) = "Mickey"
strArray(2, 1) = "Mouse"
strArray(2, 2) = "Mighty"
strArray(3, 1) = "Casey"
strArray(3, 2) = "Mickey"
strArray(4, 1) = "Mouse"
strArray(4, 2) = "Sean"
For i = 0 To UBound(strArray)
With Text1
.Text = .Text & "<input type=" & Chr(34) & Chr(34) & _
"text" & Chr(34) & Chr(34) & " name=" & Chr(34) & Chr(34) & _
"EmployeeName" & Chr(34) & Chr(34) & _
" value=" & strArray(i, 1) & "><br>"
.Text = .Text & "<input type=" & Chr(34) & Chr(34) & _
"text" & Chr(34) & Chr(34) & " name=" & Chr(34) & Chr(34) & _
"EmployeeName" & Chr(34) & Chr(34) & _
" value=" & strArray(i, 2) & "><br>" & vbCrLf
End With
Next
End Sub
ASKER
I still cannot get it to work...I've seen articles about server.htmlencode stuff...has it got anything to do with it?
First make sure multiline is set to true in your text1 property.
text1.text=""
for i = 0 to UBound(array,2)
text1.text=text1.text
"<input type=""text"" name=""EmployeeName"" value="&array(0,i)&"><br>"
next
text1.text=""
for i = 0 to UBound(array,2)
text1.text=text1.text
"<input type=""text"" name=""EmployeeName"" value="&array(0,i)&"><br>"
next
Arf
text1.text=""
for i = 0 to UBound(array,2)-1
if i>0 then text1.text=text1.text & vbcrlf
text1.text=text1.text & "<input type=""text""name=""Employ eeName"" value= " & array(0,i)
next
now i'm done!
text1.text=""
for i = 0 to UBound(array,2)-1
if i>0 then text1.text=text1.text & vbcrlf
text1.text=text1.text & "<input type=""text""name=""Employ
next
now i'm done!
shang_lan:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
Experts: Post your closing recommendations! Who deserves points here?
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
Experts: Post your closing recommendations! Who deserves points here?
shang_lan, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:
Save as PAQ -- No Refund.
DanRollins -- EE database cleanup volunteer
Moderator, my recommended disposition is:
Save as PAQ -- No Refund.
DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
for i = 0 to UBound(array,2)
response.write "<input type=""text"" name=""EmployeeName"" value="""&array(0,i)&"""><
next