Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2006

Tip: Looking for answers? Try searching our database.

How to write to html textbox

Thread view: 
allan.madriaga@gmail.com - 20 Mar 2006 06:45 GMT
Hello,

Sorry for such a newbie question.
I want to retrieve information from a database and display the results
into relating textboxes.
What java function do I use to access and write to an already existing
textbox on an html page?

Thanks in advance.
Allan
Nandu - 20 Mar 2006 06:51 GMT
i think

to read   textbox.getText()
and to write textbox.setText("STring or Message")

hope this is correct
allan.madriaga@gmail.com - 20 Mar 2006 16:22 GMT
Thanks for the reply Nandu. You are correct. getText()  is to read the
textbox value but I guess my problem is accessing it. What I am doing
is I am writing a. aspx page and using j# (basically java) for the
server-side scripting. Between the <script> tags at the top of the html
page, I am writing some functions. One of these functions will write to
the textbox. My problem is that I cannot access the textbox within the
<script> tags. The textbox is not within its scope.

Any Ideas?

Thanks,
Allan
Oliver Wong - 20 Mar 2006 21:52 GMT
> Thanks for the reply Nandu. You are correct. getText()  is to read the
> textbox value but I guess my problem is accessing it. What I am doing
[quoted text clipped - 5 lines]
>
> Any Ideas?

   .NET has its own (in my opinion weird) order-of-execution rules. From
what I understand, any action the user executes on ASPX controls will cause
a resubmit to occur to the server for processing. Check that you're using an
ASPX textbox, and not an HTML one.

   Other than that, try a .NET newsgroup, instead of a Java one.

   - Oliver
Hal Rosser - 20 Mar 2006 22:48 GMT
> Sorry for such a newbie question.
> I want to retrieve information from a database and display the results
> into relating textboxes.
> What java function do I use to access and write to an already existing
> textbox on an html page?

When java is creating the Web page to display the data, just add the 'value'
attribute to the html tag.
<input type="text" name="CompanyName" value="ABC corporation" />
the words "ABC corporation would appear in the text box.
I'm not sure you asked the question like you meant to.
geeker87@gmail.com - 21 Mar 2006 12:16 GMT
Okay, I'm not familiar with aspx or anything, but I think I know what
your trying to do.

You can't access the textbox because aspx won't allow you to, or it has
already been rendered by the browser? (i.e. that part of the html
output has already been sent..).

Trick: Use javascript.

<input type="text" name="foo" id="bar"/>

inyour script, output a couple of lines of javascript to the page:
<script type="javascript">document.getElementById('bar').setValue("ABC
Corporation");</script>

Thats just off the top of my head and I don't use JS much so it might
not be 100% correct.

-- Matt
Hal Rosser - 21 Mar 2006 23:04 GMT
> Okay, I'm not familiar with aspx or anything, but I think I know what
> your trying to do.
[quoted text clipped - 13 lines]
> Thats just off the top of my head and I don't use JS much so it might
> not be 100% correct.

I assumed the user was using java (perhaps jsp) to access the database and
to display the data in text boxes.
Since the text boxes are created at the time of creating the html page, I
assumed the OP was asking the wrong question, or made wrong assumptions.
Java does not access the page after it has been rendered - but JAVASCRIPT
can. But Javascript can not access the database.
The best solutions involves html, css, java, servlets, and javascript.
Oliver Wong - 22 Mar 2006 18:38 GMT
> Java does not access the page after it has been rendered - but JAVASCRIPT
> can. But Javascript can not access the database.

   JavaScript can ask the browser to make an HTTP request. In responce to
this request, the HTTP server can query the DB, then formulate an XML
document representing the results of the query, and return that to
JavaScript.

   That's the basis on which AJAX is built.

   - Oliver
Hal Rosser - 23 Mar 2006 03:42 GMT
> > Java does not access the page after it has been rendered - but JAVASCRIPT
> > can. But Javascript can not access the database.
[quoted text clipped - 7 lines]
>
>     - Oliver

Ah yes - AJAX
But keep in mind that client-side javascript still does not access the
database
- the request you speak of is sent to the server,
and then javascript can process the response the server returns.
Java still does not access the text box.
(We agree.)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.