I need to disable 2 listboxes when a checkbox is checked. The code below behaves properly in IE but the listboxes do not disable in Firefox and Chrome. When the checkbox, cb_SameAccess is checked, I need to prevent the user from being able to select a value from the listboxes, system and region. These listboxes are created using coldfusion code.
<cfif isdefined("formerrors.sameas_empid")><span class=errors>>></span></cfif>
<!--<td width=280 class=default><span class="errors">*</span> Request same access as employee (T-ID):</td>-->
<td><input type="checkbox" name="cb_SameAccess" id="cb_SameAccess" value=1 onclick="disableSystemRegion()">Same access as employee (TID, XID):<br></td>
<!--<td colspan=2><input type="checkbox" id="cb_Role" onclick="enableDates()">Act as another role for a period of time<br></td>-->
<td class="default">
<input type="text" size=10 name="sameas_empid" value="#htmlEditFormat(sameas_empid)#">
</td>
</tr>
</table>
</div> <!--- applicantInfo --->
<div id="systemRegion">
<table border=1 style="margin-bottom:10px;">
<tr id="divnewaccess2">
<td class="default" colspan="2">
<span class="errors">*</span> If provided, this will speed up processing of your application.
</td>
</tr>
<!--<tr id="divnewaccess3" style="display:none">-->
<tr id="systemID">
<cfif isdefined("formerrors.region")><span class=errors>>></span></cfif>
<td width=280 class=label>#say('system')#(s):</td>
<td width=300 id="colSystem">
<cf_customlistbox
selectattr='name="system" class=small size=3 multiple'
values="SKED,OATS,SMC,SRM,TOMCAT"
options="SKED,OATS,SMC,SRM/SGR,TOMCAT"
default="#system#">
</td>
</tr>
<tr id="regionID">
<cfif isdefined("formerrors.region")><span class=errors>>></span></cfif>
<td width=280 class=label>#say('region')#(s):</td>
<td width=300 id="colRegion">
<cf_dblistbox
datasource="#application.DSN#"
query="SELECT region as value,description AS label
FROM SRM_region
WHERE 1=1 and province!=''
ORDER BY region "
default="#region#"
selectattr='class=small name="region" size=4 multiple'>
</td>
</tr>
</table>
</div> <!--- systemRegion --->
When the checkbox is checked, it will call the javascript function, disableSystemRegion()
function disableSystemRegion()
{
if(document.getElementById('cb_SameAccess').checked)
{
alert("not enabled");
<cfset system = "testSystem">
<cfset region = "testRegion">
//jQuery("input[type='text']").attr("disabled", 'disabled');
//jQuery("input[type='text']").prop("disabled", true);
//document.getElementById('sameAccess').disabled = true;
//document.getElementById('system').disabled = true;
//document.getElementsByName('colSystem').setAttribute('disabled',true);
document.getElementById('colSystem').setAttribute("disabled","disabled");
document.getElementById('colRegion').setAttribute("disabled","disabled");
//document.getElementById('system').setAttribute("disabled","disabled");
//document.getElementById('region').setAttribute("disabled","disabled");
//document.getElementById('region').disabled = true;
}
else
{
alert("enabled");
//document.getElementById('sameAccess').disabled = false;
//document.getElementById('sameAccess').setAttribute('disabled',false);
//document.getElementById('colSystem').setAttribute('disabled',false);
//document.getElementById('colRegion').setAttribute('disabled',false);
//document.getElementsByName('colSystem').removeAttribute("disabled");
//document.getElementById('system').removeAttribute("disabled");
//document.getElementById('region').removeAttribute("disabled");
document.getElementById('colSystem').removeAttribute("disabled");
document.getElementById('colRegion').removeAttribute("disabled");
// document.getElementById('region').disabled = false;
}
}
It behaves properly in IE, but I cannot get it to disable in Firefox and Chrome. Any help will be appreciated. Thanks in advance! Below is my code for the form.
<form class="entryform" id="entryform" name="entryform" action="#ME#" method="post"> <!--- Don't use name attribute in form element, use id --->
<!--<form id="entryform" action="#ME#" method="post">-->
<input type="hidden" name="mode" value="save">
<div class="header" id="header">
<img width=50 height=50 src="#application.IMAGEDIR#/account_application.gif"> #say('account_application_step1')#
</div> <!--- header --->
<div class="tableInstructions1" id="instructions1">
<table style="border:solid red 1px;" class="body">
<tr>
<td>
<p class=section><b>#say('account_application_approval_new')#</b></p>
<p class=body"><span class="errors">*</span> #say('employee_updates_not_include')#</p>
</td>
</tr>
</table>
</div> <!--- instructions1 --->
<div id="instructions2">
<p class=body>
#say('account_approval')#
#say('return_to_srm')#
</p>
</div> <!--- instructions2 --->
<div id="applicantInfo">
<p class=section>#say('account_application_info')#:</p>
<table frame="border" style="margin-bottom:10px;">
<tr>
<cfif isdefined("formerrors.userid")><span class=errors>>></span></cfif>
<td width=280 class=label nowrap>#say('employee_id')# (e.g. 12345):</td>
<td class="default"><input type="text" size=10 name="userid" value="#htmlEditFormat(userid)#">
[ <a class="body" href="javascript: checkuserid();">#say('verify')#</a> ]
</td>
</tr>
<tr>
<td class="default" colspan="2">
<span class="errors">*</span> If contractor, please provide your XID.
</td>
</tr>
<tr>
<cfif isdefined("formerrors.firstname")><span class=errors>>></span></cfif>
<td width=280 class=label>#say('firstname')#:</td>
<td><input type="text" size=20 name="firstname" value="#htmlEditFormat(firstname)#"></td>
</tr>
<tr>
<cfif isdefined("formerrors.lastname")><span class=errors>>></span></cfif>
<td width=280 class=label>#say('lastname')#:</td>
<td><input type="text" size=20 name="lastname" value="#htmlEditFormat(lastname)#"></td>
</tr>
<tr>
<cfif isdefined("formerrors.email")><span class=errors>>></span></cfif>
<td width=280 class=label>#say('email')#:</td>
<td><input type="text" size=20 name="email" value="#htmlEditFormat(email)#"></td>
</tr>
<tr>
<cfif isdefined("formerrors.phone")><span class=errors>>></span></cfif>
<td width=280 class=label>#say('phone_number')#:</td>
<td><input type="text" size=20 name="phone" onblur=validatePhoneNum() value="#htmlEditFormat(phone)#"></td>
</tr>
<tr>
<cfif isdefined("formerrors.sameas_empid")><span class=errors>>></span></cfif>
<!--<td width=280 class=default><span class="errors">*</span> Request same access as employee (T-ID):</td>-->
<td><input type="checkbox" name="cb_SameAccess" id="cb_SameAccess" value=1 onclick="disableSystemRegion()">Same access as employee (TID, XID):<br></td>
<!--<td colspan=2><input type="checkbox" id="cb_Role" onclick="enableDates()">Act as another role for a period of time<br></td>-->
<td class="default">
<input type="text" size=10 name="sameas_empid" value="#htmlEditFormat(sameas_empid)#">
</td>
</tr>
</table>
</div> <!--- applicantInfo --->
<div id="systemRegion">
<table border=1 style="margin-bottom:10px;">
<tr id="divnewaccess2">
<td class="default" colspan="2">
<span class="errors">*</span> If provided, this will speed up processing of your application.
</td>
</tr>
<!--<tr id="divnewaccess3" style="display:none">-->
<tr id="systemID">
<cfif isdefined("formerrors.region")><span class=errors>>></span></cfif>
<td width=280 class=label>#say('system')#(s):</td>
<td width=300 id="colSystem">
<cf_customlistbox
selectattr='name="system" class=small size=3 multiple'
values="SKED,OATS,SMC,SRM,TOMCAT"
options="SKED,OATS,SMC,SRM/SGR,TOMCAT"
default="#system#">
</td>
</tr>
<tr id="regionID">
<cfif isdefined("formerrors.region")><span class=errors>>></span></cfif>
<td width=280 class=label>#say('region')#(s):</td>
<td width=300 id="colRegion">
<cf_dblistbox
datasource="#application.DSN#"
query="SELECT region as value,description AS label
FROM SRM_region
WHERE 1=1 and province!=''
ORDER BY region "
default="#region#"
selectattr='class=small name="region" size=4 multiple'>
</td>
</tr>
</table>
</div> <!--- systemRegion --->
<div id="date">
<table border=1>
<tr>
<td colspan=2><input type="checkbox" name="cb_Role" value=1 id="cb_Role" onclick="enableDates()">Act as another role for a period of time<br></td>
</tr>
<tr>
<cfif isdefined("formerrors.act_startdate")><span class=errors>>></span></cfif>
<cfset ico.cal = '<img alt="Calendar" border=0 height=13 width=13 src="#application.IMAGEDIR#/icons/calendar.gif">'>
<td width=280 class="label"> Start Date:</td>
<td>
<input type="text" id="txtStartDate" name="act_startdate" size="13" disabled>
<!--<img alt="Calendar" border=0 height=13 width=13 src="/srm/images/icons/calendar.gif"> -->
<!--I am a useless link-->
<a id="startDateID" href="javascript: date(document.entryform.act_startdate);">#ico.cal#</a>
<!--<img alt="Calendar" border=0 height=13 width=13 src="/srm/images/icons/calendar.gif"></a> -->
</td>
</tr>
<tr>
<cfif isdefined("formerrors.act_enddate")><span class=errors>>></span></cfif>
<td width=280 class="label"> End Date:</td>
<td>
<input type="text" id="txtEndDate" name="act_enddate" size="13" disabled>
<a id="endDateID" href="javascript: date(document.entryform.act_enddate);">#ico.cal#</a>
<!--<img alt="Calendar" border=0 height=13 width=13 src="/srm/images/icons/calendar.gif">-->
</td>
</tr>
</table>
</div> <!--- date --->
<div id="comments">
<p class=section>#say('comments_and_special_instructions')#</p>
<ul class="body">
<!--<div id="divnewaccess4" style="display:none">-->
<div id="divnewaccess4">
<li>#say('systems_and_regions')#?
<li>#say('duties_and_dep')#?
</div>
<!--<div width=200 id="divneedmore2" style="display:none">-->
<div width=200 id="divneedmore2">
<li>Need Access for particular function, please specify name of function or function ID.</li>
<li>If Job duties,department or Profile changed, please specify old and new both responsibilities.</li>
</div>
<li>#say('additional_details')#.
</ul>
<cfif isdefined("formerrors.comments")><span class=errors valign=top>>></span><br></cfif>
</div> <!--- comments --->
<div id="textarea">
<textarea name="comments" cols=60 rows=5>#htmlEditFormat(comments)#</textarea>
<input type="submit" value="#say('submit')#">
<input onClick="document.location.href = '#application.WWWROOT#/';" type="button" value="#say('cancel')#">
<input type="hidden" name="accesstypehidden" id="accesstypehidden" value="#accesstypehidden#">
</div> <!--- textarea --->
</form>
</body>
The problem is that colSystem and colRegion are the ids of table cells, and not the ids of the controls you want to disable. So, you make the entire table cell disabled.
<td width=300 id="colSystem">
While IE behaves differently, FF and Chrome do not make elements disabled if parent is disabled.
Check out this small example in FF and IE, you will notice the difference:
http://jsfiddle.net/3BmKc/
Related
Greeting,
I need to avoid validation for required field. When I click one button and this field will be required, and form will not submitted unless... And if I click another button, required field will be ignored, and the form submitted(Both are buttons within the same form for example).
<cfform name="SubmitToHR" action="Action.cfm">
<table>
<tr>
<td class="Form" bgcolor="FFFBF0">#Var#</td>
<td width="39">
<cfinput type="Text" value="#Comments#" name="Comment" size="39" maxlength="100" lass="Text5" style="height:21" required="no">
</td>
<td width="127">
<cfinput name="CheckDate" type="datefield" value="#Paycheck#" class="Text" style="height:21" size="18" required="yes" message="Select Date">
</td>
</tr>
</table>
<table>
<tr>
<td class="Center">
<cfinput name="Operation" type="submit" class="ButtonOrange" value="Submit">
</td>
</tr>
<tr>
<td class="Center">
<cfinput name="Operation" type="submit" class="ButtonRed" value="Not Approve">
</td>
</tr>
Something like this?
<script>
function checkInput(mode)
{
if (mode == 1) {
if (SubmitToHR.CheckDate.value.length == 0)
{
window.alert('Select Date');
} else {
document.forms['SubmitToHR'].submit();
}
} else if (mode == 2) {
document.forms['SubmitToHR'].submit();
}
return false;
}
</script>
<cfset Var = "Test1">
<cfset Comments = "Test1">
<cfset Paycheck = "01/01/2020">
<form name="SubmitToHR" method="post" action="Action.cfm">
<cfoutput>
<table>
<tr>
<td class="Form" bgcolor="FFFBF0">#Var#</td>
<td width="39">
<input type="Text" value="#Comments#" name="Comment" size="39" maxlength="100" class="Text5" style="height:21" required="no">
</td>
<td width="127">
<input name="CheckDate" type="Text" value="#Paycheck#" class="Text" style="height:21" size="18" required="no" message="Select Date">
</td>
</tr>
</table>
<table>
<tr>
<td class="Center">
<input name="Operation" type="button" class="ButtonOrange" value="Submit" onclick="checkInput(1);">
</td>
</tr>
<tr>
<td class="Center">
<input name="Operation" type="button" class="ButtonRed" value="Not Approve" onclick="checkInput(2);">
</td>
</tr>
</table>
</cfoutput>
</form>
I have wrote in scripting a simple question list, I need the responses to be returned in a txt file via email when the person hits submit. The front end of the file works, the email creates but the form does not post. Can anyone help with this scripting please?
Coding listed below:
<form action="mailto:test#yahoo.com?subject=Test" id="form" method="post" name="form" >
<!-- PAGE HEADER -->
<table bgcolor=#D1DEE5>
<tr>
<td width="833px"align="center">
<input class="title" name="Title" value="Customer Satisfaction Survey">
</td>
</tr>
</table>
<!-- QUESTIONS -->
<p>
<table>
<tr>
<td>
<p> Welcome message
<p>
</ul>
</td>
</tr>
</table>
<br>
<table>
<tr class="shaded">
<td align="left">
<p><b>Please tell us based on your experience, how satisfied you are with the following services:</b>
</td>
<td align="center" width="50px">Very satisfied</td>
<td align="center" width="50px">Satisfied</td>
<td align="center" width="50px">Dissatisfied</td>
<td align="center" width="50px">Very Dissatisfied</td>
<td align="center" width="50px">N/A</td>
</tr>
<tr>
<td>A</td>
<td align="center" width="50px"><input type="radio" name="q1" value="Very satisfied"></td>
<td align="center" width="50px"><input type="radio" name="q1" value="Satisfied"></td>
<td align="center" width="50px"><input type="radio" name="q1" value="Dissatisfied"></td>
<td align="center" width="50px"><input type="radio" name="q1" value="Very Dissatisfied"></td>
<td align="center" width="50px"><input type="radio" name="q1" value="N/A"></td>
</tr>
</table>
<br>
<table class="outlineTable" bgcolor=#D1DEE5>
<tr>
<td align="left" rowspan=5 width=500 style="vertical-align:top" style="padding-top:5px">
<p><b>Please add comments to explain your answers</b>
<br><textarea name="Comments10" id="Comments10" rows="7" cols="55"></textarea>
</td>
<td align="left">
Month being scored
</td>
<td align="left" class="submitButton">
<input class="name" name="Month">
</td>
</tr>
<tr>
<td align="left">
Name
</td>
<td align="left" class="submitButton">
<input class="name" name="Name">
</td>
</tr>
<tr>
<td align="left">
Date
</td>
<td align="left" class="submitButton">
<input class="name" name="Date">
</td>
</tr>
<tr>
<td align="left">
</td>
<td align="left" class="submitButton">
<input class="button2" type="submit" value="Click here to submit results">
</td>
</tr>
</table>
<br>
<table bgcolor=#D1DEE5>
<tr>
<td align="center">
<h1> Many thanks for taking the time to complete this survey
</td>
</tr>
</table>
<p>
</form>
</body>
</html>
I, getting a lot of errors in validator but I don't understand the reasons of it.
end tag for "form" omitted, but OMITTAG NO was specified
required attribute "action" not specified
<div class="serch_block">
<form method="post" action="/search">
<table>
<tr>
<td>
<input type="text" class="form_in" name="search" value="" />
</td>
<td>
<input type="image" src="/design/img/button.jpg" name="submit" style="width:20px;height:19px;" onfocus='this.value="";' value="Поиск" />
</td>
</tr>
</table>
</form>
</div>
document type does not allow element "span" here; missing one of "th", "td" start-tag
<tr>
<td width="30" valign="top" align="right" class="text2" style="padding-top:10px;padding-right: 62px;">Email:</td>
<td><input type="text" class="form_in" name="email" /></td>
<span id="error_email" style="color:#ff0000;" class="<?php if(!isset($errors['email']))echo 'invisible';?>">Name and / or E-mail / are required!</span>
</tr>
Can you help me with it?
Here is the form.
<form action="/" method="post">
<table align="center" border="0">
<tr class="boss">
<td width="30" valign="top" align="left" class="text2news">Имя:
</td>
<td>
<input type="text" class="form_in" name="name" />
<span id="error_name" style="color:#ff0000" class="invisible"></span> </td>
<!--</td> -->
</tr>
<tr>
<td width="30" valign="top" align="right" class="text2" style="padding-top:10px;padding-right: 62px;">Email:</td>
<td ><input type="text" class="form_in" name="email" /></td>
<span id="error_email" style="color:#ff0000;" class="invisible">Имя и /или E-mail/ обязательны для заполенения!</span>
</tr>
<tr class="registrationBot">
<td><input type="submit" name="subscribe" value="подписаться" /></td>
<td><input type="submit" name="unsubscribe" value="отписаться" /><input type="submit" name="cleenerror" value="закрыть" /></td>
</tr>
<tr>
<td colspan="2" style="color:#ff0000"></td>
</tr>
</table>
</form>
I want to use two forms inside a JSP page, in which one form is of enctype="multipart/form-data" and another is of simple Post method, but it's not working. How should I deal with this?
1)
<form action="NewUserRegn" method="POST">
<table class="mai">
<tr>
<td>
<table class="entry">
<tr class="entry">
<th class="entry" colspan="2">
Personal Details
</th>
</tr>
<tr>
<td class="entry">
Candidate's Name :<br>
<p>(As given in Matriculation Certificate)</p>
</td>
<td class="entry">
<input type="text" name="cdname" size="35" />
</td>
</tr>
<tr>
<td class="entry">
Gender :
</td>
<td class="entry">
<input type="radio" name="gender" value="Male" />Male
<input type="radio" name="gender" value="Female" />Female
</td>
</tr>
</table>
</form>
2)
<form name="docs"
action="NewUserRegn"
method="POST"
enctype="multipart/form-data">
<table class="mai">
<tr>
<td>
<table class="entry">
<tr>
<th class="entry" colspan="2">
Documents Upload
</th>
</tr>
<tr>
<td class="entry">
Photograph : <input type="file" name="photo" accept="image/*"/>
</td>
<td class="entry">
Signature : <input type="file" name="sign" accept="image/*"/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<table class="mai">
<tr>
<td>
<input type="submit"
value="Recheck"
name="recheck" /></center>
</td>
<td>
<input type="submit" value="Submit" />
</td>
</tr>
</table>
</form>
my question is how would I use an HTML::Template tag inside a value of form field to change that field. For example
<table border="0" cellpadding="8" cellspacing="1">
<tr>
<td align="right">File:</td>
<td>
<input type="file" name="upload" value= style="width:400px">
</td>
</tr>
<tr>
<td align="right">File Name:</td>
<td>
<input type="text" name="filename" style="width:400px" value="" >
</td>
</tr>
<tr>
<td align="right">Title:</td>
<td>
<input type="text" name="title" style="width:400px" value="" />
</td>
</tr>
<tr>
<td align="right">Date:</td>
<td>
<input type="text" name="date" style="width:400px" value="" />
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="button" value="Cancel">
<input type="submit" name="action" value="Upload" />
</td>
</tr>
</table>
I want the value to have a <TMPL_VAR> variable in it.
You use it the same way you'd use a template variable anywhere else:
<input type="text" name="date" style="width:400px" value="<TMPL_VAR NAME=date>" />
Yeah, it's ugly and it breaks your HTML validator. Which is one of the many reasons why I like Template Toolkit better.