•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,593 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,520 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1481 | Replies: 7
![]() |
| |
•
•
Join Date: May 2006
Posts: 58
Reputation:
Rep Power: 3
Solved Threads: 0
I use the following code to display the user name on the website.. like
"Welcome Kaushik"
i want to access the user first name from my JS function.
i tried
but not able to access! any idea..
"Welcome Kaushik"
<jsp:useBean id="adminUser" class="bss.BSSUserDetailsDo" scope="session"/> <font size="4" color="brown" face="verdana"> <bean:message key="Bss.user.welcome"/> //comes from some property file abcd.property <jsp:getProperty name="adminUser" property="firstName"/> </font>
i want to access the user first name from my JS function.
i tried
var name = document.getElementById('firstName');but not able to access! any idea..
Put the text data in their own container tags. Also don't use <font> tags, they are deprecated in favor of stylesheets. Something like :
You were erroneously using the bean property 'firstName' to access the element of the DOM. You have got to realize that the server side constructs you are using have got nothing to do with the generated text. The user only gets the processed JSP file.
<jsp:useBean id="adminUser" class="bss.BSSUserDetailsDo" scope="session"/> <div style='font: normal 12px verdana; color: brown;'> <bean:message key="Bss.user.welcome"/> <span id='firstName'><jsp:getProperty name="adminUser" property="firstName"/></span> </div>
You were erroneously using the bean property 'firstName' to access the element of the DOM. You have got to realize that the server side constructs you are using have got nothing to do with the generated text. The user only gets the processed JSP file.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: May 2006
Posts: 58
Reputation:
Rep Power: 3
Solved Threads: 0
thanx for your response S.O.S.. i have made the changes as you told.
now when i try to access it and display on my page using " name.value " it displays "undefined". What i might have done wrong??
i saw my page source code after executing the page.. the source is some thing like this
where Tommy is the name i want to acces.Do you think its correct?
now when i try to access it and display on my page using " name.value " it displays "undefined". What i might have done wrong??
i saw my page source code after executing the page.. the source is some thing like this
<div style='font: normal 12px verdana; color: brown;'> Welcome <span id="firstName"> Tommy </span> </div>
where Tommy is the name i want to acces.Do you think its correct?
•
•
Join Date: May 2006
Posts: 58
Reputation:
Rep Power: 3
Solved Threads: 0
hay another thing..
this is a new thing which came with the change..
i made a function such that if the user types the same name as "Tommy" it should execute.
And the funny thing is as soon as i press "t" or "T" it gets executed.
this is a new thing which came with the change..
i made a function such that if the user types the same name as "Tommy" it should execute.
And the funny thing is as soon as i press "t" or "T" it gets executed.
•
•
Join Date: May 2006
Posts: 58
Reputation:
Rep Power: 3
Solved Threads: 0
friend while i was trying i found the following code also give the same problem.. why is it so. If the code below works then my problem will be solved!
i changed the code from http://www.w3schools.com/dhtml/tryit...html_dom_color
<html>
<body>
<h1 id="header">My header</h1>
<script type="text/javascript">
document.getElementById('header').style.color="red"
var a = document.getElementById('header');
document.write(a.value);
</script>
<p><b>Note:</b> It is the script that changes the style of the element!</p>
</body>
</html>i changed the code from http://www.w3schools.com/dhtml/tryit...html_dom_color
Last edited by kaushik259106 : Sep 10th, 2007 at 6:47 am. Reason: added some more info.
•
•
Join Date: May 2006
Posts: 58
Reputation:
Rep Power: 3
Solved Threads: 0
Friend i was able to solve my problem using JSP within JS but i will wait for the answer ! I want to learn!
ThanX
ThanX
<div style='font: normal 12px verdana; color: brown;'> Welcome<span id="firstName">Tommy</span> </div>
innerHTML' property. Something like document.getElementById('firstName').innerHTML> And the funny thing is as soon as i press "t" or "T" it gets executed.
You need to show me the event handling code.
>
var a = document.getElementById('header');>
document.write(a.value);Again the same mistake. Access the inner HTML of a non-form element using the '
innerHTML' property. Something like alert(a.innerHTML). I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Accessing HTML checkboxes with php and javascript (PHP)
- IE Will Not Open Anymore (Viruses, Spyware and other Nasties)
- Use Java to remove a block of html from a number of files? (Java)
- HTML Complete (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Remove/Hide Adress Bar Navigation bar
- Next Thread: how to use javasript in .net



Hybrid Mode