471,599 Members | 931 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

calling javascript within the value attribute of an html tag

69
Hi guys,

I wanted to set the value of a textbox to be the username of whoever is logged into my application.
In the login page, a session variable username was set to be the username of whoever successfully logged in.

On the form itself i have a text box called operators that would show this username but i am running into some trouble. A username is the persons name in common and Capital letters as follows eg. John Smith's username would be JohnSmith
However, In the textbox i want to see John Smith as the value
This is where my javascript opname() function comes in. It parses the username and adds a space.

what i have so far is as follows (So wrong)
Expand|Select|Wrap|Line Numbers
  1.  
  2. <input type="text" name="operators" id="operators" size="40" <? if (isset($_SESSION['username']))?>  value="return opname("<? $_SESSION['username'] ?> ");" />
  3.  
  4.  

The opname javascript code is working ,....I just dont know how to call it within the Value attribute
Can someone please help me
Dec 4 '07 #1
1 3498
drhowarddrfine
7,435 Expert 4TB
You cannot do that because it assumes the browser is interpreting the html tags and attributes as anything but tags and attributes. The browser does not do this.
Dec 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.