HighDots Forums  

Issue with readonly text field and JavaScript function

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Issue with readonly text field and JavaScript function in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Julian McMaster
 
Posts: n/a

Default Issue with readonly text field and JavaScript function - 11-04-2005 , 08:44 PM






I have an ASP that I load from a database table. Several fields are date
fields. If the date field has a value in the table, I make the input field
readonly to prevent the users from overwriting the stored data. However, I
have a single date field at the top of the form that I need to use to allow
a user to apply that date to all date fields on the form, except for the
readonly ones. I cannot seem to get this to work. If I use the disabled
attribute in the text field and in the script below, it works fine... but I
can't disable the text fields because I cannot then post data from them to
the database. Here's the script:

function apply_date_all(theForm){
//apply date in txtdateall box to every date field on page except readonly
ones
var dateval = theForm.txtDateForAll.value;
if (dateval == ""){return false}
var len = theForm.length;
for(i=0;i<len;i++){
if(theForm.elements[i].type == "text"){ //if its a text field
if(theForm.elements[i].name.substring(0,9) == "userdate_"){
if(theForm.elements[i].readonly == false){
theForm.elements[i].value = dateval;
}
}
}
}
}

Basically, I need to disallow updates to the readonly fields via Javascript,
but allow updates to the fields that are NOT readonly. Can anyone see the
problem in my script?

Thanks for the assistance.

Julian



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.