473,326 Members | 2,090 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,326 software developers and data experts.

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 2554
In article <40**********************@lon-reader.news.telstra.net>,
TC****@elders.com.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.******@blueyonder.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="rowColour1">
&nbsp;Dated:&nbsp;
<input type="text" name="CIRDateDay" id="CIRDateDay" value="" size="2"
readonly="true">/
<input type="text" name="CIRDateMonth" id="CIRDateMonth" value=""
size="2" readonly="true">/
<input type="text" name="CIRDateYear" id="CIRDateYear" value=""
size="4" readonly="true">
<input class="button" type="button" name="CIRDate" id="CIRDate"
value="Calendar" onClick="showCalendar();">
</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.CIRDateDay.value != "") &&
(advice.CIRDateMonth.value != "") &&
(advice.CIRDateYear.value != "")) {
// Show the values and set OK to advance
alert("1. Day Month Year = >" + advice.CIRDateDay.value + "< >" +
advice.CIRDateMonth.value + "< >" + advice.CIRDateYear.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.******@blueyonder.co.invalid> 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.******@blueyonder.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="rowColour1">
&nbsp;Dated:&nbsp;
<input type="text" name="CIRDateDay" id="CIRDateDay" value=""
size="2"
readonly="true">/
<input type="text" name="CIRDateMonth" id="CIRDateMonth" value=""
size="2" readonly="true">/
<input type="text" name="CIRDateYear" id="CIRDateYear" value=""
size="4" readonly="true">
<input class="button" type="button" name="CIRDate" id="CIRDate"
value="Calendar" onClick="showCalendar();">
</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.CIRDateDay.value != "") &&
(advice.CIRDateMonth.value != "") &&
(advice.CIRDateYear.value != "")) {
// Show the values and set OK to advance
alert("1. Day Month Year = >" + advice.CIRDateDay.value + "< >" +
advice.CIRDateMonth.value + "< >" + advice.CIRDateYear.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.elements['CIRDateDay'].value != '' ) &&
...

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

Good luck,
Mike

[1] For example,
document.formName.formControl.value

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

--
Michael Winter
M.******@blueyonder.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.formName.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
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...
12
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...
4
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...
13
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...
0
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...
8
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
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...
2
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. ...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.