473,804 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving the value of a readonly text field

Hi all.

I'm not sure why I'm having problems with this but if I try to retrieve the
value of a readonly text form I get back that the object is undefined.

The reason the text is readonly is because it's a date which I set via a
calendar javascript program (associated with a button) only so the user
can't put something silly in requiring validation.

The form send the data correctly when submitted it just doesn't seem to be
able to be read.

I'm sure I'm missing something simple but I can't seem to find it.

Thanks in advance for any help.

All the best,
Tony

Jul 20 '05 #1
7 2602
In article <40************ **********@lon-reader.news.tel stra.net>,
TC****@elders.c om.au enlightened us with...
Hi all.

I'm not sure why I'm having problems with this but if I try to retrieve the
value of a readonly text form I get back that the object is undefined.


If you take your car into a mechanic's, do you tell him or her that it's
broke and then leave?

IOW, post testable code or a URL. :)

--
--
~kaeli~
A little rudeness and disrespect can elevate a meaningless
interaction to a battle of wills and add drama to an
otherwise dull day.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
On Tue, 20 Jan 2004 17:19:12 +1030, Tony Cooke <TC****@elders. com.au>
wrote:
I'm not sure why I'm having problems with this but if I try to retrieve
the value of a readonly text form I get back that the object is
undefined.


Your method of reading the value is obviously at fault. However, without
any snippets of the relevant HTML and JavaScript code, there's no way to
help you properly.

Please give a URL, or a partial copy (showing the relevant areas), of the
page in question.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3
> If you take your car into a mechanic's, do you tell him or her that it's
broke and then leave?

IOW, post testable code or a URL. :)

--
--
~kaeli~
A little rudeness and disrespect can elevate a meaningless
interaction to a battle of wills and add drama to an
otherwise dull day.


Hi Kaeli.

Good point... but usually I give a vague indication to the guy or gal then I
leave. I'm no mechanic. :-)

OK. A brief description (ie. vague indication :-)...

Clicking on a button on a form fills in the read only text fields which
contain a date. The reason why they're read only is that I want the user to
click on the button to enter the date and not try and enter it manually
(thus requiring more validation than necessary). The problem is that the
date is mandatory if they select "Yes" to a previous field and I need to
check to see if a date has been entered before allowing them to proceed. I
suppose I could use a hidden field but I believe this should work too.

Here is snippets from the code to look at.

I have a form named "advice" and I have the following within the body of the
HTML.
....
<td class="rowColou r1">
&nbsp;Dated:&nb sp;
<input type="text" name="CIRDateDa y" id="CIRDateDay " value="" size="2"
readonly="true" >/
<input type="text" name="CIRDateMo nth" id="CIRDateMont h" value=""
size="2" readonly="true" >/
<input type="text" name="CIRDateYe ar" id="CIRDateYear " value=""
size="4" readonly="true" >
<input class="button" type="button" name="CIRDate" id="CIRDate"
value="Calendar " onClick="showCa lendar();">
</td>
....

Clicking on the button will bring up the Calendar and from the selection
fill in CIRDateDay, CIRDateMonth & CIRDateYear, each of which is read only.

In the head of the HTML I have the following to check that something is in
there before proceeding to the next page:

....
if ((advice.CIRDat eDay.value != "") &&
(advice.CIRDate Month.value != "") &&
(advice.CIRDate Year.value != "")) {
// Show the values and set OK to advance
alert("1. Day Month Year = >" + advice.CIRDateD ay.value + "< >" +
advice.CIRDateM onth.value + "< >" + advice.CIRDateY ear.value +"<");
} else {
alert("A date must be entered for when the previous Statement of Advice
was entered.");
}
....

Running this brings back an alert box containing:

1. Day Month Year = >undefined< >undefined< >undefined<

I hope this enough info... oh, and can I have the brakes replaced as I find
it doesn't stop in time and the insurance company is after me. :-)

Thanks Kaeli.

Jul 20 '05 #4
Hi Mike.

I've replied to a previous post by Kaeli with snippets so hopefully that
helps.

Thanks for your reply.

All the best,
Tony
"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:op******** ******@news-text.blueyonder .co.uk...
On Tue, 20 Jan 2004 17:19:12 +1030, Tony Cooke <TC****@elders. com.au>
wrote:
I'm not sure why I'm having problems with this but if I try to retrieve
the value of a readonly text form I get back that the object is
undefined.


Your method of reading the value is obviously at fault. However, without
any snippets of the relevant HTML and JavaScript code, there's no way to
help you properly.

Please give a URL, or a partial copy (showing the relevant areas), of the
page in question.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

Jul 20 '05 #5
On Wed, 21 Jan 2004 09:38:26 +1030, Tony Cooke <TC****@elders. com.au>
wrote:

<snip>
<td class="rowColou r1">
&nbsp;Dated:&nb sp;
<input type="text" name="CIRDateDa y" id="CIRDateDay " value=""
size="2"
readonly="true" >/
<input type="text" name="CIRDateMo nth" id="CIRDateMont h" value=""
size="2" readonly="true" >/
<input type="text" name="CIRDateYe ar" id="CIRDateYear " value=""
size="4" readonly="true" >
<input class="button" type="button" name="CIRDate" id="CIRDate"
value="Calendar " onClick="showCa lendar();">
</td>
...

Clicking on the button will bring up the Calendar and from the selection
fill in CIRDateDay, CIRDateMonth & CIRDateYear, each of which is read
only.

In the head of the HTML I have the following to check that something is
in there before proceeding to the next page:

...
if ((advice.CIRDat eDay.value != "") &&
(advice.CIRDate Month.value != "") &&
(advice.CIRDate Year.value != "")) {
// Show the values and set OK to advance
alert("1. Day Month Year = >" + advice.CIRDateD ay.value + "< >" +
advice.CIRDateM onth.value + "< >" + advice.CIRDateY ear.value +"<");
} else {
alert("A date must be entered for when the previous Statement of
Advice
was entered.");
}


Odd, because the values are displayed properly in IE 6 (Win) and Opera
7.23 (Win). May I ask what browser you are using?

The only explanation that I could give at the moment is that some browsers
don't accept the shortcut method[1] when id attributes are used.

Try using the collection method[2] to access the form controls. Near the
beginning of the code snippet above, add (for later simplicity):

var adviceForm = document.forms['advice'];

Then access the form controls like this:

if(( adviceForm.elem ents['CIRDateDay'].value != '' ) &&
...

I can't guarantee that that will work, but give it a shot.

Good luck,
Mike

[1] For example,
document.formNa me.formControl. value

[2] For example,
document.forms['formName'].elements['formControl'].value

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #6
Hi Mike.

Bit late over there isn't it... or don't you have work tomorrow (today?).
Odd, because the values are displayed properly in IE 6 (Win) and Opera
7.23 (Win). May I ask what browser you are using?
I'm using IE 6 SP1.
I can't guarantee that that will work, but give it a shot.
Gave it a shot but it didn't seem to work. Same error.
Good luck,
Mike
I need it. :-)
[1] For example,
document.formNa me.formControl. value

[2] For example,
document.forms['formName'].elements['formControl'].value


Thanks anyway. I may try making them not readonly before the check then
turning them back to readonly after.

Thanks again Mike.

All the best,
Tony
Jul 20 '05 #7
OK Mike, I think I've just taken out the "Idiot of the Year" award.

I've used the calendar somewhere else and copied the fields for the date
(day, month, year) to the other area.

I've changed the name= part in the other area but not the id= part. So I had
2 fields with the same id.

Changed them to be different and now all is OK.

Sorry to have wasted your time. Thanks for your help though.

All the best,
Tony
Jul 20 '05 #8

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

Similar topics

16
11501
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not an object... the function is like so: function calc_total() { var x,i,base,margin,total,newmargin,newtotal; base = document.frmKitAmount.txtTotalKitValue.value; margin = document.frmKitAmount.margin.value/100;
12
7016
by: Susan Cranford | last post by:
Please forgive, I have looked at so much info I can't figure out how to put it together even though I know it must be fairly simple. I have an array of input text boxes (txtDOBn) where n is created at load. On the onchange event I want to calc the age and show in adjacent input text boxes that are readonly and also arrays (an age calced for each DOB entered). I was going to use the datediff function in vbscript to do the calc. Can...
4
15732
by: crjunk | last post by:
I want to set a textbox's ReadOnly value to the OPPOSITE value that the CheckBox has. For example: If the user checks the CheckBox then the ReadOnly property for the TextBox is set to False. The default value of the TextBox is set to false. Am I on the right path or am I totally off in left field? <input type="checkbox" name="chkCode1" value="ON" onclick="document.DisplayCodes.txtGrossPayroll1.readOnly !=...
13
10151
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the parent table. ----------------------------
0
1107
by: cjbland | last post by:
First off I apologize if this has been discussed before, I'm not certain how to search for what I'm looking for so I figured I'd throw this out there and see what I got. I am working with a DetailsView (Insert mode) in ASP.NET 2.0 and one of the fields I give a default value. <asp:DetailsView ....> <asp:TemplateField HeaderText="Date Entered" SortExpression="d_entered">
8
1653
by: hanseymoon | last post by:
How do you create a text input box, which shows a default value of 1+ and blocks the user from deleting it? Thanks so much! :))
6
5860
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList ID="FldType_add" Runat="server" DataSource='< %#GetFieldType()%>' DataValueField="Type" DataTextField="Type" /> Oce the page is loaded all the values are added to the dropdown list. But when I thought of getting the selected value from the...
2
2009
by: 4Ankit | last post by:
hello all, i am having some difficulty retrieving information from my form. I want to add content in my table but the content i want to add to the table is what the user inputs in my form. Basically i want to know how i retrieve information from the form so i can disaply it in the table. i have put the code i am using below, the feature i cannot get to work is the change content function. I want the email address entered by the...
1
7087
by: mark | last post by:
Forgive me if this seems like a stupid question but I need help... I'm trying to do a simple online form that emails me the results from a few fields. Here is the code: <form action="http://cm1web1/WebSurveyComponents/script/ processform.asp" method="post">
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
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
10594
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
10343
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
10331
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
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6861
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();...
3
3001
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.