473,785 Members | 2,297 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help prefilling input field usin JS

Don
I thought I had this figured out, and have been able to do it in PHP on the server, but, how do I
prefill an input field with a cookie value using JavaScript in a client-side page?

Thanks,
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Jul 23 '05 #1
10 2278
"Don" <no@adr.com> wrote in message
news:tu******** *************** *********@4ax.c om...
I thought I had this figured out, and have been able to do it in PHP on the server, but, how do I prefill an input field with a cookie value using JavaScript in a client-side page?
Thanks,
Don


Will this help? Watch for word-wrap.

<html>
<head>
<title>coookie. htm</title>
<script type="text/javascript">
function coookie() {
document.getEle mentById("data" ).value = document.cookie ;
}
</script>
</head>
<body onload="coookie ()">
<form>
<input type="text" name="data" size="100">
</form>
</body>
</html>
Jul 23 '05 #2
Don
On Mon, 20 Dec 2004 16:37:40 GMT, "McKirahan" <Ne**@McKirahan .com> wrote:
"Don" <no@adr.com> wrote in message
news:tu******* *************** **********@4ax. com...
I thought I had this figured out, and have been able to do it in PHP on

the server, but, how do I
prefill an input field with a cookie value using JavaScript in a

client-side page?

Thanks,
Don


Will this help? Watch for word-wrap.

<html>
<head>
<title>coookie .htm</title>
<script type="text/javascript">
function coookie() {
document.getEle mentById("data" ).value = document.cookie ;
}
</script>
</head>
<body onload="coookie ()">
<form>
<input type="text" name="data" size="100">
</form>
</body>
</html>

Thanks McKirahan. I'll give it a try. It sure is nice knowing you're out there to help out.
Thanks much, and have a Happy Holiday Season.
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Jul 23 '05 #3
Don
On Mon, 20 Dec 2004 16:37:40 GMT, "McKirahan" <Ne**@McKirahan .com> wrote:
"Don" <no@adr.com> wrote in message
news:tu******* *************** **********@4ax. com...
I thought I had this figured out, and have been able to do it in PHP on

the server, but, how do I
prefill an input field with a cookie value using JavaScript in a

client-side page?

Thanks,
Don


Will this help? Watch for word-wrap.

<html>
<head>
<title>coookie .htm</title>
<script type="text/javascript">
function coookie() {
document.getEle mentById("data" ).value = document.cookie ;
}
</script>
</head>
<body onload="coookie ()">
<form>
<input type="text" name="data" size="100">
</form>
</body>
</html>

McKirahan,

I tried your suggestion, and it works just great with IE. But can't seem to get any prefill with
Netscape. Doesn't Netscape allow prefills?

Thanks,
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Jul 23 '05 #4
"Don" <no@adr.com> wrote in message
news:gf******** *************** *********@4ax.c om...

[snip]
McKirahan,

I tried your suggestion, and it works just great with IE. But can't seem to get any prefill with Netscape. Doesn't Netscape allow prefills?

Thanks,
Don


Change
document.getEle mentById("data" ).value = what;
to
document.forms[0].data.value = what;

What version of NS are you running?

I don't know when getElementById( ) was supported.
Jul 23 '05 #5
"McKirahan" <Ne**@McKirahan .com> wrote in message
news:8wTxd.2331 49$V41.22654@at tbi_s52...
"Don" <no@adr.com> wrote in message
news:gf******** *************** *********@4ax.c om...

[snip]
McKirahan,

I tried your suggestion, and it works just great with IE. But can't
seem to get any prefill with
Netscape. Doesn't Netscape allow prefills?

Thanks,
Don


Change
document.getEle mentById("data" ).value = what;
to
document.forms[0].data.value = what;

What version of NS are you running?

I don't know when getElementById( ) was supported.


I meant, change
document.getEle mentById("data" ).value = document.cookie ;
to
document.forms[0].data.value = document.cookie ;
Jul 23 '05 #6
On Tue, 21 Dec 2004 11:09:56 GMT, McKirahan <Ne**@McKirahan .com> wrote:

[snip]

[To Don:]
What version of NS are you running?


It wouldn't matter.

As I've said to you a couple of times in the past, document.getEle mentById
is *NOT* - I repeat, *NOT* - allowed to return elements that have a
matching name. IE, if you haven't noticed by now, is not a browser that
should be used for primary testing of Web documents. It's too lenient - a
very bad thing in my opinion.

If you need to retrieve elements document-wide based on their names, use
the document.getEle mentsByName method. Alternatively, use the forms and
elements collection, which I think is always preferable when accessing a
form control within a form.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #7
Don
On Tue, 21 Dec 2004 11:59:20 GMT, "McKirahan" <Ne**@McKirahan .com> wrote:
"McKirahan" <Ne**@McKirahan .com> wrote in message
news:8wTxd.233 149$V41.22654@a ttbi_s52...
"Don" <no@adr.com> wrote in message
news:gf******** *************** *********@4ax.c om...

[snip]
> McKirahan,
>
> I tried your suggestion, and it works just great with IE. But can't

seem
to get any prefill with
> Netscape. Doesn't Netscape allow prefills?
>
> Thanks,
> Don


Change
document.getEle mentById("data" ).value = what;
to
document.forms[0].data.value = what;

What version of NS are you running?

I don't know when getElementById( ) was supported.


I meant, change
document.getEle mentById("data" ).value = document.cookie ;
to
document.forms[0].data.value = document.cookie ;

Great! That did it. Thanks much McKirahan.
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Jul 23 '05 #8
Don
BTW, I'm running Netscape 7.2
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Jul 23 '05 #9
"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:opsjcz14iy x13kvk@atlantis ...
On Tue, 21 Dec 2004 11:09:56 GMT, McKirahan <Ne**@McKirahan .com> wrote:

[snip]

[To Don:]
What version of NS are you running?


It wouldn't matter.

As I've said to you a couple of times in the past, document.getEle mentById
is *NOT* - I repeat, *NOT* - allowed to return elements that have a
matching name. IE, if you haven't noticed by now, is not a browser that
should be used for primary testing of Web documents. It's too lenient - a
very bad thing in my opinion.

If you need to retrieve elements document-wide based on their names, use
the document.getEle mentsByName method. Alternatively, use the forms and
elements collection, which I think is always preferable when accessing a
form control within a form.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.


Mike,

The rules keep changing and it's hard to keep up.

Can you point me to some good documentation regarding
document.getEle mentsById
and
document.getEle mentsByName
usage? Thanks.
Jul 23 '05 #10

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

Similar topics

2
9746
by: HolaGoogle | last post by:
Hi all, Can you please tell me what's wrong with my code??? i do have this database in wich i have to field.One is a "yes/no" field and another one is "number" field. To display the yes/no field in my asp form i use a checkbox and fot he other field i use a normal text box. if the yes/no field is checked then the other field is enabled otherwise it has to be disabled.Here's what i've done so far: Do While Not ObjRS.EOF <td><input...
5
1939
by: J. J. Cale | last post by:
Little astrology program has 2 text input boxes for birth dates. There are 3 selects for day month year that will supply output to whichever text input had the focus last. If the user picks from the list boxes the relative text input field is formatted d/m/y, the format that the cgi is expecting. The user can also input directly to the text inputs and I would like to route whatever the user inputs through a filter using regexes wherever...
4
2007
by: Adrienne | last post by:
I am the first to admit that I know bupkis about javascript, except that sometimes I need it to do something client side that I can't do server side. Anyway, here's my problem: <input type="text" name="ticket" id="ticket"> <input type="text" name="amount" id="amount"> My ASP script defaults ticket to be 30.00 and amount to be 600.00. What
5
8451
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform' action='ins_op.php' method='post'>"; lots of form stuff
5
2451
by: sourabh | last post by:
Hi I have a basic qus. I am writing a middle-tier component. I have constructor which takes 3 inputs, here's how it looks internal ClassName(Database dbToUse, Int64 pk,DateTime Date) { } Now , i want to know should I validate all the inputs before i start using
18
2270
by: Ed Jay | last post by:
<disclaimer>js newbie</disclaimer> My page has a form comprised of several radio buttons. I want to poll the buttons to determine which button was selected and convert its value to a string. I then want to use the string on the same page. My script is: function checkRadio(field) { for(var i=0; i < field.length; i++) {
4
2761
by: georges the man | last post by:
hey guys, i ve been posting for the last week trying to understand some stuff about c and reading but unfortunaly i couldnt do this. i have to write the following code. this will be the last time i ask for an entire code or u can give me the outine of what to do and i ll do it by myself. the description is the following: the program will read a text file that contains historical price of a stock. The program will allow users to query...
2
3157
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
4
1581
by: Paul David Buchan | last post by:
Hello, I'm attempting to write a program to read in database files (.dbf). When I do it all as a single procedure in main, everything works. However, what I really want, is to pass the database filename to a function, and have it pass back an array containing the database contents, and some parameters telling me the dimensions of the array. I've succeeded in getting my function to read in the dbf file, and it returns the dimensions of...
0
9489
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10100
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.