Click here to Skip to main content
15,900,818 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The following is a html code segment:

XML
<tr>
<td>Address</td>
<td><table>
<tr><td><input type="text" class="text"     name="address1" placeholder="Address line1" /></td></tr>
<tr><td><input type="text" class="text"     name="address2" placeholder="Address line2" /></td></tr>
<tr><td><input type="text" class="text" name="address3" placeholder="Address line3" /></td></tr>
</table>
</td>
</tr>



I have an address string in session scope.
value="${sessionScope.updatePersonBean.address}"

This string has three lines of address in it.

Now, I need to display each line as the default value in each of the three input address lines in the html form.
Posted
Updated 5-Mar-14 5:29am
v3

You can use the JavaScript string split function to split the address on the separator and assign each address to the appropriate DOM element.
 
Share this answer
 
HTML line separator is </br> :-).

—SA
 
Share this answer
 
Comments
[no name] 6-Mar-14 1:54am    
I think you didn't read the question carefully. The OP wants to dynamically split an address field that he gets from a Java Bean and populate the Html fields.
Sergey Alexandrovich Kryukov 6-Mar-14 2:02am    
No, I just pretty demonstratively refuse to do guesswork.

I just don't know which part of this sophisticated problem is not clear to OP. Not knowing some HTML syntax is as likely as not knowing Javascript capabilities or libraries. You inferred the use of Java Bean just from the string which I consider just the example of data.

My point here is: it's bad to be too good at guesswork. OP should understand that the answer is defined by the question. Garbage in, garbage out.

—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900