I am attempting to clean up the email output in this Mailto form so that it is more easily readable. To do so I would like be able to pass the header fields into the email and format the output for easier reading.
This is my first attempt at creating an HTML based form. I have it created so that the fields work they way I would like them to in the form itself but the mailto output is still very messy.
<!DOCTYPE html>
<html>
<body>
<form name= "ReportRequest" action="mailto:cbostic#entirafamilyclinics.com?subject=Report Request" method="post" enctype="text/plain">
<Label><h1>Report Request Form</h1></Label>
<br>
<Label><h2>Requestor Information:</h2></Label>
<br>
Date Requested: <input type="date" name="Date Requested:">
<br>
Email Address: <input type = "text" name = "Email Address:">
<br>
<script>
// Put this script in header or above select element
function check(elem) {
// use one of possible conditions
if (elem.value == 'Adjust Current Report')
//if (elem.selectedIndex == 1)
{
document.getElementById("other-div").style.display = 'block';
document.getElementById("other-div2").style.display = 'block';
document.getElementById("other-div3").style.display = 'block';
document.getElementById("fre").style.display = 'none';
document.getElementById("ques").style.display = 'none';
document.getElementById("use").style.display = 'none';
document.getElementById("rec").style.display = 'none';
document.getElementById("format").style.display = 'none';
document.getElementById("patdet").style.display = 'none';
document.getElementById("excl").style.display = 'none';
document.getElementById("clinic").style.display = 'none';
document.getElementById("provider").style.display = 'none';
document.getElementById("age").style.display = 'none';
document.getElementById("daterange").style.display = 'none';
document.getElementById("diag").style.display = 'none';
document.getElementById("cptcode").style.display = 'none';
document.getElementById("visit").style.display = 'none';
document.getElementById("enc").style.display = 'none';
document.getElementById("gender").style.display = 'none';
document.getElementById("reptyp").style.display = 'none';
document.getElementById("rephead").style.display = 'none';
document.getElementById("critq").style.display = 'none';
document.getElementById("gen1").style.display = 'none';
document.getElementById("gen2").style.display = 'none';
document.getElementById("gen3").style.display = 'none';
document.getElementById("gen4").style.display = 'none';
document.getElementById("gen5").style.display = 'none';
document.getElementById("fin1").style.display = 'none';
document.getElementById("fin2").style.display = 'none';
document.getElementById("fin3").style.display = 'none';
document.getElementById("fin4").style.display = 'none';
document.getElementById("fin5").style.display = 'none';
document.getElementById("fin6").style.display = 'none';
document.getElementById("fin7").style.display = 'none';
document.getElementById("fin8").style.display = 'none';
document.getElementById("fin9").style.display = 'none';
document.getElementById("fin10").style.display = 'none';
document.getElementById("med1").style.display = 'none';
document.getElementById("med2").style.display = 'none';
document.getElementById("med3").style.display = 'none';
document.getElementById("med4").style.display = 'none';
document.getElementById("med5").style.display = 'none';
document.getElementById("med6").style.display = 'none';
document.getElementById("med7").style.display = 'none';
} else
if (elem.value == 'Create New Report')
{
document.getElementById("other-div").style.display = 'none';
document.getElementById("other-div2").style.display = 'none';
document.getElementById("other-div3").style.display = 'none';
document.getElementById("fre").style.display = 'block';
document.getElementById("ques").style.display = 'block';
document.getElementById("use").style.display = 'block';
document.getElementById("rec").style.display = 'block';
document.getElementById("format").style.display = 'block';
document.getElementById("patdet").style.display = 'block';
document.getElementById("excl").style.display = 'block';
document.getElementById("clinic").style.display = 'block';
document.getElementById("provider").style.display = 'block';
document.getElementById("age").style.display = 'block';
document.getElementById("daterange").style.display = 'block';
document.getElementById("diag").style.display = 'block';
document.getElementById("cptcode").style.display = 'block';
document.getElementById("visit").style.display = 'block';
document.getElementById("enc").style.display = 'block';
document.getElementById("gender").style.display = 'block';
document.getElementById("reptyp").style.display = 'block';
document.getElementById("rephead").style.display = 'block';
document.getElementById("critq").style.display = 'block';
}
}
</script>
Type of Request:
<select id="RequestType" name = "Type of Request:" onchange= "check(this);">
<option value="Please Choose">Please Choose</option>
<option value="Create New Report">Create New Report</option>
<option value="Adjust Current Report">Adjust Current Report</option>
</select>
<br>
<div id="other-div" style="display:none">
Report Name: <input type = "text" name = "Report Name:">
</div>
<div id="other-div2" style="display:none">
Report Location(if known): <input type = "text" name = "Report Location:">
<br>
</div>
<div id="fre" style="display:none">
Report Frquency:
<select name = "Report Frequency:">
<option value="Daily">Daily</option>
<option value="Weekly">Weekly</option>
<option value="Monthly">Monthly</option>
<option value="One Time">One Time</option>
<option value="Other">Other</option>
</select>
<br>
</div>
Request Priority:
<select name = "Report Priority:">
<option value="Low">Low</option>
<option value="Medium">Medium</option>
<option value="High">High</option>
</select>
<br>
Deadline Date: <input type="date" name="Deadline Date:">
<br>
<Label><h2>Report Creation Questions:</h2></Label>
<br>
<div id="ques" style="display:none">
Please Describe the question(s) you are attempting to answer:
<br>
<textarea rows = "5" cols = "50" name = "Please Describe the question(s) you are attempting to answer:">
</textarea>
<br>
</div>
<div id="use" style="display:none">
How will the report be used?
<br>
<textarea rows = "5" cols = "50" name = "How will the report be used?">
</textarea>
<br>
</div>
<div id="rec" style="display:none">
Who will receive the report?
<br>
<textarea rows = "5" cols = "50" name = "Who will receive the report?">
</textarea>
<br>
</div>
<div id="format" style="display:none">
What format would you like the report in? (excel or pdf)
<select name = "What format would you like the report in? (excel or pdf):">
<option value="Select">Select</option>
<option value="excel">Excel</option>
<option value="PDF">PDF</option>
</select>
<br>
</div>
<div id="patdet" style="display:none">
Are patient details needed for this report?
<br>
<textarea rows = "5" cols = "50" name = "Are patient details needed for this report?">
</textarea>
<br>
</div>
<div id="excl" style="display:none">
Does any data need to be excluded?
<br>
<textarea rows = "5" cols = "50" name = "Does any data need to be excluded?">
</textarea>
<br>
</div>
<div id="other-div3" style="display:none;">
<label>What is being adjusted (if changing a current report)?
<br>
<textarea rows = "5" cols = "50" name = "What is being adjusted (if changing a current report)?">
</textarea>
</label>
<br>
</div>
<div id="critq" style="display:none">
<Label><h2>What Is the Criteria for the Report?</h2></Label>
<br>
<Label>(Ex: Report only needs to be run for Shoreview Clinic, patients 6 years of age and older, with a diagnosis of asthma using CPT codes 1234, 5678)</Label>
<br>
</div>
<div id="clinic" style="display:none;">
Clinics: <input type = "text" name = "Clinics:">
<br>
</div>
<div id="provider" style="display:none;">
Providers: <input type = "text" name = "Providers:">
<br>
</div>
<div id="age" style="display:none;">
Age Range: <input type = "text" name = "Age Range:">
<br>
</div>
<div id="daterange" style="display:none;">
Date Range: <input type = "text" name = "Date Range:">
<br>
</div>
<div id="diag" style="display:none;">
Diagnosis: <input type = "text" name = "Diagnosis:">
<br>
</div>
<div id="cptcode" style="display:none;">
CPT Code(s): <input type = "text" name = "CPT Code(s):">
<br>
</div>
<div id="visit" style="display:none;">
Visit Type(s): <input type = "text" name = "Visit Type(s):">
<br>
</div>
<div id="enc" style="display:none;">
Encounter Types: <input type = "text" name = "Encounter Types:">
<br>
</div>
<div id="gender" style="display:none;">
Gender: <input type = "text" name = "Gender:">
<br>
</div>
<script>
// Put this script in header or above select element
function check2(elem2) {
// use one of possible conditions
if (elem2.value == 'Select')
//if (elem.selectedIndex == 1)
{
document.getElementById("gen1").style.display = 'none';
document.getElementById("gen2").style.display = 'none';
document.getElementById("gen3").style.display = 'none';
document.getElementById("gen4").style.display = 'none';
document.getElementById("gen5").style.display = 'none';
document.getElementById("fin1").style.display = 'none';
document.getElementById("fin2").style.display = 'none';
document.getElementById("fin3").style.display = 'none';
document.getElementById("fin4").style.display = 'none';
document.getElementById("fin5").style.display = 'none';
document.getElementById("fin6").style.display = 'none';
document.getElementById("fin7").style.display = 'none';
document.getElementById("fin8").style.display = 'none';
document.getElementById("fin9").style.display = 'none';
document.getElementById("fin10").style.display = 'none';
document.getElementById("med1").style.display = 'none';
document.getElementById("med2").style.display = 'none';
document.getElementById("med3").style.display = 'none';
document.getElementById("med4").style.display = 'none';
document.getElementById("med5").style.display = 'none';
document.getElementById("med6").style.display = 'none';
document.getElementById("med7").style.display = 'none';
}else
if (elem2.value == 'general')
{
document.getElementById("gen1").style.display = 'block';
document.getElementById("gen2").style.display = 'block';
document.getElementById("gen3").style.display = 'block';
document.getElementById("gen4").style.display = 'block';
document.getElementById("gen5").style.display = 'block';
document.getElementById("fin1").style.display = 'none';
document.getElementById("fin2").style.display = 'none';
document.getElementById("fin3").style.display = 'none';
document.getElementById("fin4").style.display = 'none';
document.getElementById("fin5").style.display = 'none';
document.getElementById("fin6").style.display = 'none';
document.getElementById("fin7").style.display = 'none';
document.getElementById("fin8").style.display = 'none';
document.getElementById("fin9").style.display = 'none';
document.getElementById("fin10").style.display = 'none';
document.getElementById("med1").style.display = 'none';
document.getElementById("med2").style.display = 'none';
document.getElementById("med3").style.display = 'none';
document.getElementById("med4").style.display = 'none';
document.getElementById("med5").style.display = 'none';
document.getElementById("med6").style.display = 'none';
document.getElementById("med7").style.display = 'none';
} else
if (elem2.value == 'Financial')
{
document.getElementById("gen1").style.display = 'none';
document.getElementById("gen2").style.display = 'none';
document.getElementById("gen3").style.display = 'none';
document.getElementById("gen4").style.display = 'none';
document.getElementById("gen5").style.display = 'none';
document.getElementById("fin1").style.display = 'block';
document.getElementById("fin2").style.display = 'block';
document.getElementById("fin3").style.display = 'block';
document.getElementById("fin4").style.display = 'block';
document.getElementById("fin5").style.display = 'block';
document.getElementById("fin6").style.display = 'block';
document.getElementById("fin7").style.display = 'block';
document.getElementById("fin8").style.display = 'block';
document.getElementById("fin9").style.display = 'block';
document.getElementById("fin10").style.display = 'block';
document.getElementById("med1").style.display = 'none';
document.getElementById("med2").style.display = 'none';
document.getElementById("med3").style.display = 'none';
document.getElementById("med4").style.display = 'none';
document.getElementById("med5").style.display = 'none';
document.getElementById("med6").style.display = 'none';
document.getElementById("med7").style.display = 'none';
} else
if (elem2.value == 'Clinical')
{
document.getElementById("gen1").style.display = 'none';
document.getElementById("gen2").style.display = 'none';
document.getElementById("gen3").style.display = 'none';
document.getElementById("gen4").style.display = 'none';
document.getElementById("gen5").style.display = 'none';
document.getElementById("fin1").style.display = 'none';
document.getElementById("fin2").style.display = 'none';
document.getElementById("fin3").style.display = 'none';
document.getElementById("fin4").style.display = 'none';
document.getElementById("fin5").style.display = 'none';
document.getElementById("fin6").style.display = 'none';
document.getElementById("fin7").style.display = 'none';
document.getElementById("fin8").style.display = 'none';
document.getElementById("fin9").style.display = 'none';
document.getElementById("fin10").style.display = 'none';
document.getElementById("med1").style.display = 'block';
document.getElementById("med2").style.display = 'block';
document.getElementById("med3").style.display = 'block';
document.getElementById("med4").style.display = 'block';
document.getElementById("med5").style.display = 'block';
document.getElementById("med6").style.display = 'block';
document.getElementById("med7").style.display = 'block';
}
}
</script>
<br>
<div id="reptyp" style="display:none">
Type of Report:
<select name = "Type of Report:" onchange= "check2(this)">
<option value="Select">Select</option>
<option value="general">General</option>
<option value="Financial">Financial/Billing</option>
<option value="Clinical">Clinical/Medical</option>
</select>
<br>
</div>
<div id="rephead" style="display:none">
<Label><h2>What Headings Do You Want Displayed on Your Report?</h2></Label>
<br>
</div>
<div id="gen1" style="display:none">
<input type = "checkbox" name = "Primary Care Provider (PCP)" value= 'X'> Primary Care Provider (PCP)
</div>
<div id="gen2" style="display:none">
<input type = "checkbox" name = "Appointment Provider" value= 'X'> Appointment Provider
</div>
<div id="gen3" style="display:none">
<input type = "checkbox" name = "Encounter Date" value= 'X'> Encounter Date
</div>
<div id="gen4" style="display:none">
<input type = "checkbox" name = "Appointment Facility" value= 'X'> Appointment Facility
</div>
<div id="gen5" style="display:none">
<input type = "checkbox" name = "Insurance details" value= 'X'> Insurance details
</div>
<br>
<div id="fin1" style="display:none">
<input type = "checkbox" name = "Claim Number" value= 'X'> Claim Number
</div>
<div id="fin2" style="display:none">
<input type = "checkbox" name = "Claim Date" value= 'X'> Claim Date
</div>
<div id="fin3" style="display:none">
<input type = "checkbox" name = "Service Date" value= 'X'> Service Date
</div>
<div id="fin4" style="display:none">
<input type = "checkbox" name = "Appointment Facility" value= 'X'> Appointment Facility
</div>
<div id="fin5" style="display:none">
<input type = "checkbox" name = "Appointment Provider" value= 'X'> Appointment Provider
</div>
<div id="fin6" style="display:none">
<input type = "checkbox" name = "ICD Codes" value= 'X'> ICD Codes
</div>
<div id="fin7" style="display:none">
<input type = "checkbox" name = "CPT/HCPCS Codes" value= 'X'> CPT/HCPCS Codes
</div>
<div id="fin8" style="display:none">
<input type = "checkbox" name = "Insurance Names" value= 'X'> Insurance Names
</div>
<div id="fin9" style="display:none">
<input type = "checkbox" name = "Billed Amount" value= 'X'> Billed Amount
</div>
<div id="fin10" style="display:none">
<input type = "checkbox" name = "Amount Paid By Insurance" value= 'X'> Amount Paid By Insurance
</div>
<br>
<div id="med1" style="display:none">
<input type = "checkbox" name = "Allergies" value= 'X'> Allergies
</div>
<div id="med2" style="display:none">
<input type = "checkbox" name = "ICD Codes" value= 'X'> ICD Codes
</div>
<div id="med3" style="display:none">
<input type = "checkbox" name = "CPT/HCPCS Codes" value= 'X'> CPT/HCPCS Codes
</div>
<div id="med4" style="display:none">
<input type = "checkbox" name = "Advanced Directives" value= 'X'> Advanced Directives
</div>
<div id="med5" style="display:none">
<input type = "checkbox" name = "Problem List" value= 'X'> Problem List
</div>
<div id="med6" style="display:none">
<input type = "checkbox" name = "Medications" value= 'X'> Medications
</div>
<div id="med7" style="display:none">
<input type = "checkbox" name = "Referrals" value= 'X'> Referrals
</div>
<br>
<Label><h2>Additional information regarding your request:</h2></Label>
<br>
<textarea rows = "5" cols = "50" name = "Additional information regarding your request:">
</textarea>
<br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>
</body>
</html>
I would expect a well formatted email output including the form headers that would be easily readable.
Related
Expected the primary menu (Report Type) to be visible only. Before and After selection from Primary Menu; Other filters are not visible
Expected to only show the dates if any report selected other than R30: After selection of any R report, except R30 will make start-date and end-date visible
Expected to only show mineSite & CertificateType after selection of R30: After selection of R30 report, only mineSite (required) & certificateType is visible
Here is what I have been using (Javascript function)
function showDates(sel)
{
if(sel.value == 'R30')
{
document.getElementById('dates').style.display = 'none';
document.getElementById('m1warning').style.display = 'none';
document.getElementById('mines').style.display = '';
document.getElementById('certificate').style.display = '';
}
else if (sel.value == 'M01')
{
document.getElementById('dates').style.display = 'none';
document.getElementById('m1warning').style.display = 'inline';
document.getElementById('mines').style.display = 'none';
document.getElementById('certificate').style.display = 'none';
}
else if(sel.value == 'R01' || sel.value == 'R10' || sel.value == 'R20' || sel.value == '')
{
document.getElementById('mines').style.display = 'none';
document.getElementById('dates').style.display = '';
document.getElementById('certificate').style.display = 'none';
document.getElementById('m1warning').style.display = 'none';
}
else if(sel.value == '')
{
document.getElementById('mines').style.display = 'none';
document.getElementById('dates').style.display = 'none';
document.getElementById('certificate').style.display = 'none';
document.getElementById('m1warning').style.display = 'none';
}
}
function showOptions(sel)
{
if(sel.value == 'R30')
{
document.getElementById('dates').style.display = 'none';
document.getElementById('m1warning').style.display = 'none';
document.getElementById('mines').style.display = '';
document.getElementById('certificate').style.display = '';
}
else if (sel.value == 'M01')
{
document.getElementById('dates').style.display = 'none';
document.getElementById('m1warning').style.display = 'inline';
document.getElementById('mines').style.display = 'none';
document.getElementById('certificate').style.display = 'none';
}
else if(sel.value == 'R01' || sel.value == 'R10' || sel.value == 'R20' || sel.value == '')
{
document.getElementById('mines').style.display = 'none';
document.getElementById('dates').style.display = '';
document.getElementById('certificate').style.display = 'none';
document.getElementById('m1warning').style.display = 'none';
}
else if(sel.value == '')
{
document.getElementById('mines').style.display = 'none';
document.getElementById('dates').style.display = 'none';
document.getElementById('certificate').style.display = 'none';
document.getElementById('m1warning').style.display = 'none';
}
}
<div class="dates" id="dates">
<xsl:text>Start Date:</xsl:text>
<input id="startDate" name="startdate" type="date" size="15" placeholder="yyyy-mm-dd" style="width:150px"/>
<xsl:text> End Date:</xsl:text>
<input id="endDate" name="enddate" type="date" size="15" placeholder="yyyy-mm-dd" style="width:150px"/>
</div>
<table>
<tr>
<td>
<div class="mines" id="mines">
<form id="mine_site" name = "form2">
<span class="site_label">Mine Site: </span>
<select name="minesite" id="minesite" onchange="showOptions(this)" style="width:150px">
<option value=""/>
<xsl:variable name="mine_sites" select="$codes/code[#name eq 'employer']"/>
<xsl:for-each select="$mine_sites/item">
<xsl:element name="option">
<xsl:attribute name="value" select="#key"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:for-each>
</select>
</form>
</div>
</td>
<td>
<div class="certificate" id="certificate">
<span class="certificate_label">Certificate Type: </span>
<select name="typeOfcertificate" id="typeOfcertificate" onchange="showOptions(this)" style="width:150px">
<option value=""/>
<xsl:variable name="certificate_types" select="$codes/code[#name eq 'certiType']" />
<xsl:for-each select="$certificate_types/item">
<xsl:sort select="#order"/>
<xsl:element name="option">
<xsl:attribute name="value" select="#key"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:for-each>
</select>
</div>
</td>
</tr>
</table>
<br/>
<input type="submit" class="buttonToLink" value="Submit" onclick="beginCheckMReport()"/>
</form>
Badly stuck on how can I make the secondary filters dependent on the Primary Menu selection. And after the submission of report, making the form empty
Sorry for bothering everyone with this silly issue
I want to show hidden input fields when check "Buy on company" checkbox. It works, but if I uncheck it leaving "Is VAT exemt" checked and return: "VAT ID field" is shown with "Is VAT exemt" checkbox checked. So I want to avoid this situation.
Picture of situation:
document.getElementById('billing_company').style['display'] = 'none';
document.getElementById('billing_company_code').style['display'] = 'none';
document.getElementById('is_vat_exempt').style['display'] = 'none';
document.getElementById('is_vat_exempt_field').style['display'] = 'none';
document.getElementById('billing_vat_id').style['display'] = 'none';
document.getElementById('buy_on_company').onclick = function() {
if (this.checked) {
document.getElementById('billing_company').style['display'] = 'block';
document.getElementById('billing_company_code').style['display'] = 'block';
document.getElementById('is_vat_exempt').style['display'] = 'block';
document.getElementById('is_vat_exempt_field').style['display'] = 'block';
document.getElementById('billing_vat_id').style['display'] = 'block';
} else {
document.getElementById('billing_company').style['display'] = 'none';
document.getElementById('billing_company_code').style['display'] = 'none';
document.getElementById('is_vat_exempt').style['display'] = 'none';
document.getElementById('is_vat_exempt_field').style['display'] = 'none';
document.getElementById('billing_vat_id').style['display'] = 'none';
}
};
document.getElementById('is_vat_exempt').onclick = function() {
if (this.checked) {
document.getElementById('billing_vat_id').style['display'] = 'none';
} else {
document.getElementById('billing_vat_id').style['display'] = 'block';
}
};
<div id="buy_on_company_field">
<input type="checkbox" id="buy_on_company"><label>Buy on company</label>
</div>
<div id="billing_company_field">
<input type="text" id="billing_company" placeholder="Company name" style="display: block;">
</div>
<div id="billing_company_code_field">
<input type="text" id="billing_company_code" placeholder="Company code" style="display: block;">
</div>
<div id="is_vat_exempt_field">
<input type="checkbox" id="is_vat_exempt"><label>Is VAT exempt</label>
</div>
<div id="billing_vat_id_field">
<input type="text" id="billing_vat_id" placeholder="VAT ID field" style="display: block;">
</div>
The code for clicking on buy_on_company is always hiding or showing the billing_vat_id field. It needs to test that checkbox.
document.getElementById('billing_company').style['display'] = 'none';
document.getElementById('billing_company_code').style['display'] = 'none';
document.getElementById('is_vat_exempt').style['display'] = 'none';
document.getElementById('is_vat_exempt_field').style['display'] = 'none';
document.getElementById('billing_vat_id').style['display'] = 'none';
document.getElementById('buy_on_company').onclick = function() {
if (this.checked) {
document.getElementById('billing_company').style['display'] = 'block';
document.getElementById('billing_company_code').style['display'] = 'block';
document.getElementById('is_vat_exempt').style['display'] = 'block';
document.getElementById('is_vat_exempt_field').style['display'] = 'block';
if (document.getElementById('is_vat_exempt').checked) {
document.getElementById('billing_vat_id').style['display'] = 'none';
} else {
document.getElementById('billing_vat_id').style['display'] = 'block';
}
} else {
document.getElementById('billing_company').style['display'] = 'none';
document.getElementById('billing_company_code').style['display'] = 'none';
document.getElementById('is_vat_exempt').style['display'] = 'none';
document.getElementById('is_vat_exempt_field').style['display'] = 'none';
document.getElementById('billing_vat_id').style['display'] = 'none';
}
};
document.getElementById('is_vat_exempt').onclick = function() {
if (this.checked) {
document.getElementById('billing_vat_id').style['display'] = 'none';
} else {
document.getElementById('billing_vat_id').style['display'] = 'block';
}
};
<div id="buy_on_company_field">
<input type="checkbox" id="buy_on_company"><label>Buy on company</label>
</div>
<div id="billing_company_field">
<input type="text" id="billing_company" placeholder="Company name" style="display: block;">
</div>
<div id="billing_company_code_field">
<input type="text" id="billing_company_code" placeholder="Company code" style="display: block;">
</div>
<div id="is_vat_exempt_field">
<input type="checkbox" id="is_vat_exempt"><label>Is VAT exempt</label>
</div>
<div id="billing_vat_id_field">
<input type="text" id="billing_vat_id" placeholder="VAT ID field" style="display: block;">
</div>
One line was missing, to hide "billing_vat_id" in second 'else' statement.
document.getElementById('billing_vat_id').style['display'] = 'none';
https://i.imgur.com/QRpD12r.png
I only want certain labels and input boxes to be displayed depending on which radio button is selected. (4 radio buttons available)
Below is the code I am using which I cannot get to work, and I am pretty sure there is a cleaner way of writing this but unsure. Can anyone help?
Here are the 4 radio buttons that effect the destiny of the inputs:
<div class="radio-btn-aligning">
<span>
<label class="radio-container">Rectangle
<input type="radio" checked="checked" name="radio"
onclick="javascript:yesnoCheck();" id="RectangleCheck">
<span class="radio-checkmark"></span>
</label>
<label class="radio-container">Oval
<input type="radio" name="radio" onclick="javascript:yesnoCheck();"
id="OvalCheck">
<span class="radio-checkmark"></span>
</label>
<label class="radio-container">Round
<input type="radio" name="radio" onclick="javascript:yesnoCheck();"
id="RoundCheck">
<span class="radio-checkmark"></span>
</label>
<label class="radio-container">Custom Oblong
<input type="radio" name="radio" onclick="javascript:yesnoCheck();"
id="OblongCheck">
<span class="radio-checkmark"></span>
</label>
</span>
</div>
And here is the script:
<script type="text/javascript">
function yesnoCheck() {
if (document.getElementById('RectangleCheck').checked) {
document.getElementById('RectangleInput1').style.display = 'block';
document.getElementById('RectangleInput2').style.display = 'block';
document.getElementById('RectangleInput3').style.display = 'block';
document.getElementById('Rectangle-container1').style.display = 'block';
document.getElementById('Rectangle-container2').style.display = 'block';
document.getElementById('Rectangle-container3').style.display = 'block';
document.getElementById('OvalInput1').style.display = 'none';
document.getElementById('OvalInput2').style.display = 'none';
document.getElementById('OvalInput3').style.display = 'none';
document.getElementById('oval-container1').style.display = 'none';
document.getElementById('oval-container2').style.display = 'none';
document.getElementById('oval-container3').style.display = 'none';
document.getElementById('RoundInput1').style.display = 'none';
document.getElementById('RoundInput2').style.display = 'none';
document.getElementById('round-container').style.display = 'none';
document.getElementById('round-container2').style.display = 'none';
document.getElementById('OblongInput1').style.display = 'none';
document.getElementById('OblongInput2').style.display = 'none';
document.getElementById('OblongInput3').style.display = 'none';
document.getElementById('oblong-container1').style.display = 'none';
document.getElementById('oblong-container2').style.display = 'none';
document.getElementById('oblong-container3').style.display = 'none';
}
elseif (document.getElementById('OvalCheck').checked) {
document.getElementById('RectangleInput1').style.display = 'none';
document.getElementById('RectangleInput2').style.display = 'none';
document.getElementById('RectangleInput3').style.display = 'none';
document.getElementById('Rectangle-container1').style.display = 'none';
document.getElementById('Rectangle-container2').style.display = 'none';
document.getElementById('Rectangle-container3').style.display = 'none';
document.getElementById('OvalInput1').style.display = 'block';
document.getElementById('OvalInput2').style.display = 'block';
document.getElementById('OvalInput3').style.display = 'block';
document.getElementById('oval-container1').style.display = 'block';
document.getElementById('oval-container2').style.display = 'block';
document.getElementById('oval-container3').style.display = 'block';
document.getElementById('RoundInput1').style.display = 'none';
document.getElementById('RoundInput2').style.display = 'none';
document.getElementById('round-container1').style.display = 'none';
document.getElementById('round-container2').style.display = 'none';
document.getElementById('OblongInput1').style.display = 'none';
document.getElementById('OblongInput2').style.display = 'none';
document.getElementById('OblongInput3').style.display = 'none';
document.getElementById('oblong-container1').style.display = 'none';
document.getElementById('oblong-container2').style.display = 'none';
document.getElementById('oblong-container3').style.display = 'none';
}
elseif (document.getElementById('RoundCheck').checked) {
document.getElementById('RectangleInput1').style.display = 'none';
document.getElementById('RectangleInput2').style.display = 'none';
document.getElementById('RectangleInput3').style.display = 'none';
document.getElementById('Rectangle-container1').style.display = 'none';
document.getElementById('Rectangle-container2').style.display = 'none';
document.getElementById('Rectangle-container3').style.display = 'none';
document.getElementById('OvalInput1').style.display = 'none';
document.getElementById('OvalInput2').style.display = 'none';
document.getElementById('OvalInput3').style.display = 'none';
document.getElementById('oval-container1').style.display = 'none';
document.getElementById('oval-container2').style.display = 'none';
document.getElementById('oval-container3').style.display = 'none';
document.getElementById('RoundInput1').style.display = 'block';
document.getElementById('RoundInput2').style.display = 'block';
document.getElementById('round-container1').style.display = 'block';
document.getElementById('round-container2').style.display = 'block';
document.getElementById('OblongInput1').style.display = 'none';
document.getElementById('OblongInput2').style.display = 'none';
document.getElementById('OblongInput3').style.display = 'none';
document.getElementById('oblong-container1').style.display = 'none';
document.getElementById('oblong-container2').style.display = 'none';
document.getElementById('oblong-container3').style.display = 'none';
}
elseif (document.getElementById('OblongCheck').checked) {
document.getElementById('RectangleInput1').style.display = 'none';
document.getElementById('RectangleInput2').style.display = 'none';
document.getElementById('RectangleInput3').style.display = 'none';
document.getElementById('Rectangle-container1').style.display = 'none';
document.getElementById('Rectangle-container2').style.display = 'none';
document.getElementById('Rectangle-container3').style.display = 'none';
document.getElementById('OvalInput1').style.display = 'none';
document.getElementById('OvalInput2').style.display = 'none';
document.getElementById('OvalInput3').style.display = 'none';
document.getElementById('oval-container1').style.display = 'none';
document.getElementById('oval-container2').style.display = 'none';
document.getElementById('oval-container3').style.display = 'none';
document.getElementById('RoundInput1').style.display = 'none';
document.getElementById('RoundInput2').style.display = 'none';
document.getElementById('round-container1').style.display = 'none';
document.getElementById('round-container2').style.display = 'none';
document.getElementById('OblongInput1').style.display = 'block';
document.getElementById('OblongInput2').style.display = 'block';
document.getElementById('OblongInput3').style.display = 'block';
document.getElementById('oblong-container1').style.display = 'block';
document.getElementById('oblong-container2').style.display = 'block';
document.getElementById('oblong-container3').style.display = 'block';
}
}
</script>
And finally the input boxes and labels effected:
<label class="calc-form-label" id="rectangle-container1">Length of your pool in feet</label><input type="number" class="tabinput" name="length" min="1" id="RectangleInput1">
<label class="calc-form-label" id="rectangle-container2">Width of your pool in feet</label><input type="number" class="tabinput" name="width" min="1" id="RectangleInput2">
<label class="calc-form-label" id="rectangle-container3">Depth of your pool in feet</label><input type="number" class="tabinput" name="depth" min="1" id="RectangleInput3">
<label class="calc-form-label" id="oval-container1">Half the length of your pool in feet</label><input type="number" class="tabinput" name="half-length" min="1" id="OvalInput1">
<label class="calc-form-label" id="oval-container2">Half the width of your pool in feet</label><input type="number" class="tabinput" name="half-width" min="1" id="OvalInput2">
<label class="calc-form-label" id="oval-container3">Depth of your pool in feet</label><input type="number" class="tabinput" name="oval-depth" min="1" id="OvalInput3">
<label class="calc-form-label" id="round-container1">Radius of your pool in feet</label><input type="number" class="tabinput" name="round-radius" min="1" id="RoundInput1">
<label class="calc-form-label" id="round-container2">Depth of your pool in feet</label><input type="number" class="tabinput" name="round-depth" min="1" id="RoundInput2">
<label class="calc-form-label" id="oblong-container1">Small diameter of your pool in feet</label><input type="number" class="tabinput" name="small-diameter" min="1" id="OblongInput1">
<label class="calc-form-label" id="oblong-container2">Large diameter of your pool in feet</label><input type="number" class="tabinput" name="large-diameter" min="1" id="OblongInput2">
<label class="calc-form-label" id="oblong-container3">Length of your pool in feet</label><input type="number" class="tabinput" name="oblong-length" min="1" id="OblongleInput3">
HTML ids must be unique!
So I changed id="rectangle-container" to id="rectangle-container1" and id="rectangle-container2" and so on.
You could put all corresponding labels and inputs togerther in a div or something and then hide and display the div.
<div id='myUniqueIdForRectangle'>
<label class="calc-form-label" id="rectangle-container1">Length of your pool in feet</label>
<input type="number" class="tabinput" name="length" min="1" onclick="javascript:yesnoCheck();" id="RectangleInput1">
<label class="calc-form-label" id="rectangle-container2">Width of your pool in feet</label>
<input type="number" class="tabinput" name="width" min="1" onclick="javascript:yesnoCheck();" id="RectangleInput2">
<label class="calc-form-label" id="rectangle-container3">Depth of your pool in feet</label>
<input type="number" class="tabinput" name="depth" min="1" onclick="javascript:yesnoCheck();" id="RectangleInput3">
</div>
function yesnoCheck() {
if (document.getElementById('RectangleCheck').checked) {
document.getElementById('myUniqueIdForRectangle').style.display = 'block';
document.getElementById('myUniqueIdForRectangleForOval').style.display = 'none';
....
}
....
}
I have three radio buttons that calculate fees. When you click the first radio button it has a drop down with a checkbox if you click the checkbox it adds $3.. if the user realizes that was a mistake and does not unclick the check box and clicks another radio button it does not remove the $3 from the total until the radio buttons are clicked at least twice.
The first two radio buttons are 78.25 and the 3rd is 88.25. Click first radio button 78.25 and then the checkbox will make it 81.25, then pretend your the user change your mind and hit the second radio button it should change it back to 78.25 when you click. But it does not and it keeps 81.25 if you click the third radio button it finally realizes it and corrects itself?
I have it set up to uncheck the checkbox when another radio button is checked but for some reason the fee is not changing instantly and is delayed for some reason. Can some one please assist?
If anyone has any suggestions or advice it would be greatly appreciated!
http://jsfiddle.net/Ln1fnstb/2/
$(function(){ //added by me
$('#brandnewrv').click(function(){
calculateTotal();
});
});
function rvsPrice()
{
var rvPrice=0;
var theForm = document.forms["form"];
var brandnewRv = document.getElementById('brandnewrv');
if(brandnewRv.checked==true)
{
rvPrice=3;
}
return rvPrice;
}
//Setting Proof of Ownership Prices
//Set up an associative array
var title_prices = new Array();
title_prices["MCO"]=78.25;
title_prices["FL Title"]=78.25;
title_prices["OOS Title"]=88.25;
// Proof of Ownership Radio Buttons
function getProofOfOwnership()
{
var proofOfOwnership=0;
//Get a reference to the form id="form"
var theForm = document.forms["form"];
//Get a reference to the title the user Chooses name=ownerShip":
var ownerShip = theForm.elements["ownership"];
//Here since there are 4 radio buttons ownerShip.length = 4
//We loop through each radio buttons
for(var i = 0; i < ownerShip.length; i++)
{
//if the radio button is checked
if(ownerShip[i].checked)
{
proofOfOwnership = title_prices[ownerShip[i].value];
//If we get a match then we break out of this loop
//No reason to continue if we get a match
break;
}
}
//We return the proofOfOwnership
return proofOfOwnership;
}
function calculateTotal()
{
var titleFees = rvsPrice() + getProofOfOwnership();
var divobj = document.getElementById('totalPrice');
divobj.style.display='block';
divobj.innerHTML = "Estimated Transfer Fees $"+titleFees;
}
function hideTotal()
{
var divobj = document.getElementById('totalPrice');
divobj.style.display='none';
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<form name="form">
<label><strong>Proof of Ownership</strong></label><br />
<label class='radiolabel'><input type="radio" name="ownership" required="yes" message="Please select proof of ownership." value="MCO" onclick="calculateTotal()" onchange="statedropDown(this.value);"/>Manufacturer's Statement of Origin </label>
<label class='radiolabel'><input type="radio" name="ownership" value="FL Title" onclick="calculateTotal()" onchange="statedropDown(this.value);"/>Florida Certificate of Title </label>
<label class='radiolabel'><input type="radio" name="ownership" value="OOS Title" onclick="calculateTotal()" onchange="statedropDown(this.value);"/>Out-of-state Certificate of Title </label>
<div id="div3" style="display:none">
<div class="clearfix">
<select name="month1" id="month1" size="1">
<option value="">Choose a Month</option>
<option value="0">January</option>
<option value="1">February</option>
<option value="2">March</option>
<option value="3">April</option>
<option value="4">May</option>
<option value="5">June</option>
<option value="6">July</option>
<option value="7">August</option>
<option value="8">September</option>
<option value="9">October</option>
<option value="10">November</option>
<option value="11">December</option>
</select>
</div>
</div>
<div id="div4" style="display:none">
<!---You are not qualified to see this form.--->
</div>
<div id="div5" style="display:none">
<p><label for='brandnewrv' class="inlinelabel"> Check if Brand new RV/Motor Home</label>
<input type="checkbox" id="brandnewrv" name='brandnewrv' onclick="calculateTotal()" /></p>
</div>
<div id="totalPrice"></div>
<script type="text/javascript">
function statedropDown(ownership) {
if (ownership == "OOS Title") {
document.getElementById("div3").style.display = 'block';
document.getElementById("div4").style.display = 'none';
document.getElementById("div5").style.display = 'none';
document.getElementById("brandnewrv").checked = false;
rvsPrice();
}
else if (ownership == "FL Title") {
document.getElementById("div4").style.display = 'block';
document.getElementById("div3").style.display = 'none';
document.getElementById("div5").style.display = 'none';
document.getElementById("titlestates").selectedIndex = 0;
document.getElementById("brandnewrv").checked = false;
rvsPrice();
}
else if (ownership == "MCO") {
document.getElementById("div5").style.display = 'block';
document.getElementById("div3").style.display = 'none';
document.getElementById("div4").style.display = 'none';
document.getElementById("titlestates").selectedIndex = 0;
}
}
</script>
</form>
I think there's some more complexity than there needs to be. I think the radio buttons really just need a "click" handler that calls a modified version of the "statedropDown" function, and no "change" handler. The "statedropDown" function should be changed so that it calls "calculateTotal()" at the end. And that line that references "titlestates" needs to be commented out in the fiddle, since that part of the DOM isn't there.
<label class='radiolabel'>
<input type="radio" name="ownership" required="yes" message="Please select proof of ownership." value="MCO" onclick="statedropDown(this.value)">Manufacturer's Statement of Origin </label>
<label class='radiolabel'>
<input type="radio" name="ownership" value="FL Title" onclick="statedropDown(this.value)">Florida Certificate of Title </label>
<label class='radiolabel'>
<input type="radio" name="ownership" value="OOS Title" onclick="statedropDown(this.value)">Out-of-state Certificate of Title </label>
and then
function statedropDown(ownership) {
if (ownership == "OOS Title") {
document.getElementById("div3").style.display = 'block';
document.getElementById("div4").style.display = 'none';
document.getElementById("div5").style.display = 'none';
document.getElementById("brandnewrv").checked = false;
} else if (ownership == "FL Title") {
document.getElementById("div4").style.display = 'block';
document.getElementById("div3").style.display = 'none';
document.getElementById("div5").style.display = 'none';
//document.getElementById("titlestates").selectedIndex = 0;
document.getElementById("brandnewrv").checked = false;
} else if (ownership == "MCO") {
document.getElementById("div5").style.display = 'block';
document.getElementById("div3").style.display = 'none';
document.getElementById("div4").style.display = 'none';
//document.getElementById("titlestates").selectedIndex = 0;
}
calculateTotal();
}
Here is the updated fiddle. (I changed a couple of other minor things while tinkering with it, but I think the above changes are the key.)
Basically I have signup and signin and I they're both divs which appear and disappear on the click of a link but I wish for one to close if the other is clicked and then opened.
Example:
signin area is open and signup button is clicked. I wish for signin area to disappear and for the signup content to be revealed.
Current Code:
<script language="javascript">
function toggle() {
var ele = document.getElementById("signin");
var text = document.getElementById("signtext");
var ele2 = document.getElementById("signup");
var text2 = document.getElementById("signuptext");
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "show";
ele2.style.display = "block";
text2.innerHTML = "hide";
}
else {
ele.style.display = "block";
text.innerHTML = "hide";
ele2.style.display = "block";
text2.innerHTML = "hide";
}
}
function toggle2() {
var ele2 = document.getElementById("signup");
var text2 = document.getElementById("signuptext");
var ele = document.getElementById("signin");
var text = document.getElementById("signtext");
if(ele2.style.display == "block") {
ele2.style.display = "none";
text2.innerHTML = "show";
ele.style.display = "block";
text.innerHTML = "hide";
}
else {
ele2.style.display = "block";
text2.innerHTML = "hide";
ele.style.display = "block";
text.innerHTML = "hide";
}
}
</script>
Html :
<div id="signin" style="display: none">
<form action="loginscript.php" method="post">
<p>Username:<input type="text" id="username"></p>
<p>Password:<input type="password" id="password"> <input type="submit" value="submit"></p>
</form>
</div>
<div id="signup" style="display: none">
<h1>peek-a-boo</h1>
</div>
Try this.There is no need of creating two different functions.Lesser the number of functions=Better the code + smarter is the coder!!!!
function toggle(id){
switch(id)
{
case 'signin':
document.getElementById('signin').style.display='block';
document.getElementById('signup').style.display='none';
break;
case 'signup':
document.getElementById('signup').style.display='block';
document.getElementById('signin').style.display='none';
break;
}
HTML
<div id="signin" onclick="toggle(this.id)"> SignIN</div>
<div id="signup" onclick="toggle(this.id)"> SignUp</div>
You can invoke a function on "onclick" event and hide the div using CSS:Visibility property
<a id="myLink" href="#" onclick="MyFunction();">link text</a>
Try this one:
function signUpIn(objId) {
document.getElementById('signin').style.display = 'none';
document.getElementById('signup').style.display = 'none';
document.getElementById(objId).style.display = 'block';
}
Your html changes:
<div id="signin" style="display: block">
</div>
<div id="signup" style="display: none">
</div>
Sign Up
Sign In
Check if it works for you.
Try to grab concept from this, may not be a perfect, but still contain some learning part -
Check this working Fiddle - http://jsfiddle.net/j7LDD/
Working Code -
HTML PART -
<form id="signup" method="get" style="display:none;">
<label>SignUp Name</label>
<input type="text" name="signupname" />
<input type="submit" name="signupsubmit" value="signup" />
</form>
<form id="signin" method="get" style="display:none;">
<label>SignIn Name</label>
<input type="text" name="signinname" />
<input type="submit" name="signinsubmit" value="signin" />
</form>
<button id="signupbutton" onclick="toggle(this.id);">SignUp</button>
<button id="signinbutton" onclick="toggle(this.id);">SignIn</button>
JS PART -
<script>
function toggle( val ) {
if( "signupbutton" == val ) {
document.getElementById("signup").style.display = 'block';
document.getElementById("signin").style.display = 'none';
}
else {
document.getElementById("signin").style.display = 'block';
document.getElementById("signup").style.display = 'none';
}
}
</script>