?
Solved

Populate data into form

Posted on 2003-02-21
9
Medium Priority
?
130 Views
Last Modified: 2010-05-03
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?
0
Comment
Question by:shang_lan
9 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 7993624
You need to also encapsulate that into quotes:

for i = 0 to UBound(array,2)
response.write "<input type=""text"" name=""EmployeeName"" value="""&array(0,i)&"""><br>"
next
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 7993634
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
0
 
LVL 1

Expert Comment

by:jeffreyhamby
ID: 7993696
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:shang_lan
ID: 7998458
I still cannot get it to work...I've seen articles about server.htmlencode stuff...has it got anything to do with it?
0
 
LVL 1

Expert Comment

by:xThorx
ID: 8025157
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
0
 
LVL 1

Expert Comment

by:xThorx
ID: 8025174
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=""EmployeeName"" value= " & array(0,i)
next

now i'm done!
0
 

Expert Comment

by:CleanupPing
ID: 8901316
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?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8964060
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
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9103985
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question