• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unable to update Div tag.

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have couple of <div> in a jsp pageA . I have iframe in it which i am targeting from another jsp pageB. In the PageB , i have couple of Javascript to update both the <div> in pageA . The first update is successfull but the updating second <div> fails --that is text is getting changed but at some other place in HTML and not at the <div> area. It behaves as though it fails to see the <div>.

the difference between 2 <div> is that first <div> - which is being updated properyl simply encloses a text and resides inside table row element like

<tr>
<td colspan="2" class="xxx">
Welcome, <br/><divid="login_box">MyName.</div>
</td>
</tr>

The second div that is not getting updates encloses the whole table row like this. ( Note this row is third row in the table ).

<div id="aaa">
<tr>
<td></td>
</tr>

This is the only difference.

I am using following code in PageB to update pageA.

<script type="text/javascript">
window.parent.clear_main_menu();
window.parent.document.all.login_box_username.innerHTML = "<%=user.getUserFullName()%>.";
</script> ----------This is working good

<script type="text/javascript">
newitem = <tr><td>Language</td></tr>;
window.parent.document.all.aaa.innerHTML = newitem;
// window.parent.document.getElementById('aaa').innerHTML = newitem;
</script>-- This script is not working correctly. I was expecting the third row to change ..but it writing at the top of the table...


I am a novie in javascript ..so i would be thankful if someone explains me this.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should not be using document.all, that is outdated IE only property.

You should not have a div inside of a table that is not inside of a cell.

this is bad markup below!
<div>
<tr>
<td></td>
</tr>
</div>

Eric
 
Ram Gokul
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric . I got it to work by putting div inside the cell . but I just abstracted the problem . The original code has much more to it like having struts tag called <logic:notPresent> . So if bean is not present there would not be a <tr> at all in the first place . In my second parsing , that is thru pageB, I might have valid bean and hence I wanted to draw a table row .

But as you said , I put div inside the cell now .which mean <tr> will always be there even if the bean is not there . That is ok since a empty Row does not draw anything on the screen ( with my stylesheet class )


Now proceeding forward , I have another problem .I am using a variable in javascript like below in my jsp .( It has a struts tag )

newitem = '<logic:notEmpty name="user" property="Languages".........>';


This when parsed in JSP and sent to BRowser is giving me a "unterminated string constant" error . The line is :

newitem = '<select name="defaultLanguage" class="logonTextBox"><option value="E" selected="selected">English</option>
<option value="ZH-T">Chinese Traditional</option>
<option value="AR">Arabic</option>
<option value="FA">Persian</option>
</select>';

We can see the problem . But how do i solve this.
I dont know whhether this is javascript or JSTL tag problem.


Thanks
[ August 15, 2006: Message edited by: Ram Gokul ]
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JavaScript string literals cannot span multiple lines.
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ram Gokul:

I dont know whhether this is javascript or JSTL tag problem.



There is no JSTL in your example code.
 
Ram Gokul
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used <c:forEach> JSTL tag instead of <html:select> struts tag
Because iteration is controlled by me , i am able to use the javascript String variables and prevent line breaks.
 
Ram Gokul
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used <c:forEach> JSTL tag instead of <html:select> struts tag
Because iteration is controlled by me , i am able to use the javascript String variables and prevent line breaks.
reply
    Bookmark Topic Watch Topic
  • New Topic