Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional form field

Status
Not open for further replies.

scott69

MIS
Sep 21, 2002
4
GB
Hi,

I need help with the following if possible??

I have a form that has several fields in it, both text fields and hidden fields that are passed to a CGI program. I have some random text displayed on the form based on the date and time and that works fine.

I would like to disable at least one of the hidden fields using the date and time function so that say after 17:00 the field is disabled but after 09:00 it is enabled. As I say the time side is OK but I have no idea what code I should use to disable the hidden field. Do I insert the HTML into the javascript function or what? And if so how? Any ideas and help would be much appreciated!

Scott.
 
uh, what exactly is the hidden field for? it doesn't make sense to disable a hidden field, since it is not available for direct user input in the first place


=========================================================
while (!succeed) try();
-jeff
 
Apologies for any confusion. The field contains a value that I do not want passed after 17:00. I know the user can't modify it and that's fine, but it needs to be unavailable - i.e. the value not passed after this time.

Thanks

Scott.
 
i would have the cgi handle it...

=========================================================
while (!succeed) try();
-jeff
 
Yeah.....that's what I feared you might say. It's a third party CGI and I don't know enough to mess with that.... is there no way with javascript??

Thanks
 
well, if the field literally contains a value like "09:00", then you could do something like:

function checkField(oField) {
var arVal = oField.value.split(":");
if (parseInt(arVal[0], 10) >= 17 &&
parseInt(arVal[1], 10) > 0) oField.disabled = true;
}

and call it when the page loads, like
<body onload=&quot;checkField(document.forms[0].hiddenFieldName)&quot;>

=========================================================
while (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top