473,320 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how to use javascript write text to an Input text box

Hi,

I tried to assign some string to document.my_form.firstname.value, but
the text box does not display anything.
eg.
document.my_form.firstname.value = "Robert"

in this example, the text box area does not display Robert in the web page.

Thanks
A
Mar 24 '06 #1
3 22052
acord wrote on 24 mrt 2006 in comp.lang.javascript:
I tried to assign some string to document.my_form.firstname.value, but
the text box does not display anything.
eg.
document.my_form.firstname.value = "Robert"

in this example, the text box area does not display Robert in the web
page.


Use:

document.forms['my_form'].elements['firstname'].value = "Robert"

Your problem could be that the form is not ready, as the above only works
when the form has been set up in the DOM.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 24 '06 #2
In article <Xn********************@194.109.133.242>,
"Evertjan." <ex**************@interxnl.net> wrote:
acord wrote on 24 mrt 2006 in comp.lang.javascript:
I tried to assign some string to document.my_form.firstname.value, but
the text box does not display anything.
eg.
document.my_form.firstname.value = "Robert"

in this example, the text box area does not display Robert in the web
page.


Use:

document.forms['my_form'].elements['firstname'].value = "Robert"

Your problem could be that the form is not ready, as the above only works
when the form has been set up in the DOM.


So do it in the onload.

-- tim
Mar 24 '06 #3
Tim Streater wrote on 24 mrt 2006 in comp.lang.javascript:
In article <Xn********************@194.109.133.242>,
"Evertjan." <ex**************@interxnl.net> wrote:
acord wrote on 24 mrt 2006 in comp.lang.javascript:
> I tried to assign some string to document.my_form.firstname.value,
> but the text box does not display anything.
> eg.
> document.my_form.firstname.value = "Robert"
>
> in this example, the text box area does not display Robert in the
> web page.
>
>


Use:

document.forms['my_form'].elements['firstname'].value = "Robert"

Your problem could be that the form is not ready, as the above only
works when the form has been set up in the DOM.


So do it in the onload.


That could be done, Tim,
but why not [then!] just write the text in the
<input value='.....'

Look, no hands, .... eh javascript.

The OP is not clear over his intentions.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 24 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
4
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
3
by: anthonybrough | last post by:
I have an asp page that has a form to collect user data in a form. when the user clicks submit the input is validated. If any fields are not acceptable the user clicks on a button to go back to...
1
by: anupamaavadutha | last post by:
hi all, iam new to javascript. i have problem calling javascript functions.iam designing a calender page.here is my code. <%@ page...
1
by: anniefs | last post by:
hi help me i m so much stuck int he code and i have no time .... i used ASP VBscipt and javascript functions with MS database javascript function add records in MS DB by using ASP vbscript...
5
by: quirk | last post by:
I am trying to write a script where a page is populated with some maths questions, user answers them (it's timed but I've left this bit out), gets results on same page and ajax takes their score,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.