PDA

View Full Version : Repair Script



jonaha
10-11-2017, 02:57 AM
1) Script Title:

2) Script URL (on DD):

3) Describe problem: I need help in fixing this script



<style type="text/css"></style>

#hintbox{ /*CSS for pop up hint box */
position:absolute;
top: 0;
background-color: lightgrey;
width: 150px; /*Default width of hint.*/
padding: 3px;
border:1px solid black;
font:normal 12px Arial;
line-height:18px;
z-index:100;
border-right: 3px solid black;
border-bottom: 3px solid black;
visibility: hidden;
}

.hintanchor{ /*CSS for link that shows hint onmouseover*/
font-weight: bold;
color: navy;
margin: 3px 8px;
}



&lt;script type="text/javascript"&gt;

/***********************************************
* Show Hint script- � Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&amp;&amp;!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode &amp;&amp; document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie &amp;&amp; !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x &lt; dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie &amp;&amp; !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y &lt; dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) &amp;&amp; document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox

&lt;/script&gt;





&lt;script language="JavaScript"&gt;
<!-- Begin
function calc_headroom(form) {
var mattress = form.mattress.value;
var ceiling = form.ceiling.value;
var above = form.above.value;
var leg691 = 0
var leg692 = 0
var leg831 = 0
var leg832 = 0
var trim691 = 0
var trim692 = 0
var trim831 = 0
var trim832 = 0
var underceiling = (ceiling - above - mattress - 3);

form.under691.value = (69 - 5 - mattress - 3);
if (underceiling < form.under691.value) (form.under691.value = underceiling);
form.under831.value = (83 - 5 - mattress - 3);
if (underceiling < form.under831.value) (form.under831.value = underceiling);
form.under692.value = (69 - 10 - mattress - 3);
if (underceiling < form.under692.value) (form.under692.value = underceiling);
form.under832.value = (83 - 10 - mattress - 3);
if (underceiling < form.under832.value) (form.under832.value = underceiling);

form.a691.value = (ceiling - mattress - 3 - form.under691.value);
form.a831.value = (ceiling - mattress - 3 - form.under831.value);
form.a692.value = (ceiling - mattress - 3 - form.under692.value);
form.a832.value = (ceiling - mattress - 3 - form.under832.value);

leg691 = -(-3 - mattress - 5 - form.under691.value);
leg831 = -(-3 - mattress - 5 - form.under831.value);
leg692 = -(-3 - mattress - 10 - form.under692.value);
leg832 = -(-3 - mattress - 10 - form.under832.value);

trim691 = 69 - leg691;
trim831 = 83 - leg831;
trim692 = 69 - leg692;
trim832 = 83 - leg832;

form.top691.value = leg691 - 5;
form.top831.value = leg831 - 5;
form.top692.value = leg692 - 10;
form.top832.value = leg832 - 10;

minabove30 = "Suggestion: We recommend the Minimum Headroom Above the Mattress is 30 inches.";
mattresszero = "Error: The Mattress Thickness must be greater than zero";
mattress40 = "Error: The Mattress Thickness must be less than 40 inches";

if (mattress < 1) alert(mattresszero); // mattress must be greater than zero
if (mattress > 40) alert(mattress40); // mattress can't be greater then 40
if (above < 10) alert(minabove30); // minimum headroom above is 30

}
// End -->
&lt;/script&gt;

<center>
<form method="POST">


<table bgcolor="#ffffff" width="550" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td><h2>Height Calculator</h2>
<h4>How much headroom will I get?<br/>
Enter your specifications below and then press Calculate Headroom. </h4></td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top">
<div>
<table width="85%" align="center" cellpadding="2" cellspacing="2">
<tbody><tr>
<td width="74%">Total Mattress Thickness <a href="#" class="hintanchor" onmouseover="showhint('Enter the total thickness of the mattress and any mattress topper.', this, event, '200px')" style="text-decoration: none; vertical-align: middle; font-weight: 400;color:#900">[?]</a></td>
<td width="26%"><input name="mattress" size="3" value="8" onfocus="select()" maxlength="2"/> inches</td>
</tr>
<tr>
<td>Ceiling Height <a href="#" class="hintanchor" onmouseover="showhint('We need the ceiling height to calculate how much headroom you will get above and underneath.', this, event, '200px')" style="text-decoration: none; vertical-align: middle; font-weight: 400;;color:#900">[?]</a></td>
<td><input name="ceiling" size="3" value="96" onfocus="select()"/> inches</td>
</tr>
<tr>
<td>Minimum Headroom Above Mattress <a href="#" class="hintanchor" onmouseover="showhint('We recommend a minimum of 30 inches of headroom above.', this, event, '200px')" style="text-decoration: none; vertical-align: middle; font-weight: 400;;color:#900">[?]</a></td>
<td><input name="above" size="3" value="30" onfocus="select()"/> inches</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="right"><input value="Reset" type="reset"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input value="Calculate Headroom" onclick="calc_headroom(this.form)" type="button"/></td>
</tr>
</tbody></table><br/> <br/>

<h2><strong></strong><center>Headroom Above &amp; Underneath the Mattress</center></h2><br/>

<table width="75%" align="center" cellpadding="2" cellspacing="2">
<tbody><tr>
<td colspan="2"><strong>Using Standard Single Safety Rail</strong></td>
</tr>
<tr>
<td><strong>69" Legs</strong></td>
<td><strong>83" Legs</strong></td>
</tr>
<tr>
<td>Above &nbsp;<input name="a691" value="44" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
<td>Above &nbsp;<input name="a831" value="30" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
</tr>
<tr>
<td>Underneath&nbsp;<input name="under691" value="56" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
<td>Underneath&nbsp;<input name="under831" value="70" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
</tr>
<tr>
<td>Top of Mattress&nbsp;<input name="top691" value="64" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
<td>Top of Mattress&nbsp;<input name="top831" value="78" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2"><strong>Using Youth Double Safety Rails</strong></td>
</tr>
<tr>
<td>69" Legs</td>
<td>83" Legs</td>
</tr>
<tr>
<td>Above &nbsp;<input name="a692" value="49" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
<td>Above&nbsp;<input name="a832" value="35" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
</tr>
<tr>
<td>Underneath&nbsp;<input name="under692" value="51" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
<td>Underneath&nbsp;<input name="under832" value="65" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
</tr>
<tr>
<td>Top of Mattress&nbsp;<input name="top692" value="59" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/> </td>
<td>Top of Mattress &nbsp;<input name="top832" value="73" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"/></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><input value="Return to Previous Page" onclick="javascript:history.back()" type="button"/></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</tbody></table>

<center>
<p><img src="media/cms/html/loft_drawing_text.gif" width="485" border="0" height="339"/></p>
<table width="100%" cellspacing="2" cellpadding="2">
<tbody><tr>
<td height="33%" align="center" valign="top"><h6>Standard 69" Legs<br/>Single Safety Rail<br/><img src="media/cms/html/loft_clear_100x97.jpg" width="100" height="97" alt="Standard 69&quot; Legs with Single Safetry Rail"/></h6></td>
<td height="33%" align="center" valign="top"><h6>Extra Tall 83" Legs<br/>Single Safety Rail<br/><img src="media/cms/html/loft_extratall_100x111.jpg" width="100" height="111" alt="Extra Tall 83&quot; Legs with Single Safety Rail"/></h6></td>
<td width="33%" align="center" valign="top"><h6>Standard 69" Legs<br/>Youth (Double) Safety Rails<br/><img src="media/cms/html/youth_sdc_1468x1480_small1.jpg" width="100" height="100" alt="Standard 69&quot; Legs with Youth (Double) Safety Rails"/></h6></td>
</tr>
</tbody></table>
<p>&nbsp;</p>
</center>


</div></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>

</form></center>

jscheuer1
10-11-2017, 01:23 PM
There could also be other problems but:


<style type="text/css"></style>

#hintbox{ /*CSS for pop up hint box */
position:absolute;
top: 0;
background-color: lightgrey;
width: 150px; /*Default width of hint.*/
padding: 3px;
border:1px solid black;
font:normal 12px Arial;
line-height:18px;
z-index:100;
border-right: 3px solid black;
border-bottom: 3px solid black;
visibility: hidden;
}

.hintanchor{ /*CSS for link that shows hint onmouseover*/
font-weight: bold;
color: navy;
margin: 3px 8px;
}


should be:


<style type="text/css">

#hintbox{ /*CSS for pop up hint box */
position:absolute;
top: 0;
background-color: lightgrey;
width: 150px; /*Default width of hint.*/
padding: 3px;
border:1px solid black;
font:normal 12px Arial;
line-height:18px;
z-index:100;
border-right: 3px solid black;
border-bottom: 3px solid black;
visibility: hidden;
}

.hintanchor{ /*CSS for link that shows hint onmouseover*/
font-weight: bold;
color: navy;
margin: 3px 8px;
}
</style>


and:


&lt;script type="text/javascript"&gt;

should be:


<script>

and:


// End -->
&lt;/script&gt;


should be:


// End -->
</script>

jonaha
10-15-2017, 09:34 PM
Willing to pay to get this script fixed.

jscheuer1
10-16-2017, 01:45 AM
No need to do that, though perhaps. First, do what I suggest. If that's still not working, please post a link to the page on your site that shows what what you have so far.

Also helpful - Where did you get this script? (please link to the page where you saw it on Dynamic Drive)

jonaha
10-16-2017, 12:52 PM
Here is a link to the page that it is displayed in: https://www.nationalhomestore.com/ste_heightcalculator

It was done for me along time ago. Here is t he information about the script :

/***********************************************
* Show Hint script- � Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.

jscheuer1
10-16-2017, 01:50 PM
OK, I just looked at the page you linked to with the height calculator and the hint script there seems to be working fine. Also, looks like you fixed the problems from before like I suggested. If it's still not working for you, try clearing the browser cache and refreshing the page.

jonaha
10-16-2017, 07:00 PM
Hi,
If you increase the mattress thickness by 2" then the clearance should be decreased by 2". If you increase the ceiling height by 2" the clearance should be increased by 2". The script is not doing that.

jscheuer1
10-16-2017, 07:33 PM
That script never did that. It's a hint script, not a calculator script. The hints are now working. I'll have a closer look at it later though to see if the hint script was modified to take on calculator duties and that part is no longer working, or if there is another script, or perhaps nothing, attempting to do that part.

jonaha
10-17-2017, 03:01 PM
Can you help when you get a chance?

jscheuer1
10-17-2017, 04:11 PM
OK, it seems to work to me, except for one problem, the initial values are wrong. That is if you assume that once you hit the calculate button the values are accurate. If so, from that point on they increment and decrement in ways that are consistent with the input.

However, this one problem gives rise to two problems. First, when the page loads (really, just after the form is parsed), everything is out of sync, so the calc_headroom function should be run then in order to sync things up. And, when one hits reset, things go out of sync again, so the calc_headroom function should be run then as well.

There are various ways of doing these two things, but I would suggest first giving the form a unique id, say - "calcform" (addition highlighted):


<center>
<form method="POST" id="calcform">


<table bgcolor="#ffffff" width="550" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td><h2>Height Calculator</h2>
<h4>How much headroom will I get?<br />
Enter your specificatio . . .

Next, find the reset button and add the highlighted:


<td colspan="2" align="right"><input value="Reset" type="reset" onclick="setTimeout(function(){calc_headroom(document.getElementById('calcform'));}, 100); return true;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

Finally, after the form, add this short script as shown:


</tbody></table>
</td>
</tr>
</tbody></table>

</form></center>

<script>
calc_headroom(document.getElementById('calcform'));
</script>
</div>


<div class="clearboth"></div>

Save and use it like that.

The browser cache may need to be emptied, and/or the page refreshed to see changes.

jonaha
10-18-2017, 04:05 PM
It is still not working. I appreciate your help.
Here is a link https://www.nationalhomestore.com/ste_heightcalculator



<style type="text/css">

#hintbox{ /*CSS for pop up hint box */
position:absolute;
top: 0;
background-color: lightgrey;
width: 150px; /*Default width of hint.*/
padding: 3px;
border:1px solid black;
font:normal 12px Arial;
line-height:18px;
z-index:100;
border-right: 3px solid black;
border-bottom: 3px solid black;
visibility: hidden;
}

.hintanchor{ /*CSS for link that shows hint onmouseover*/
font-weight: bold;
color: navy;
margin: 3px 8px;
}

</style>

<script type="text/javascript">

/***********************************************
* Show Hint script- � Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox

</script>





<script language="JavaScript">
<!-- Begin
function calc_headroom(form) {
var mattress = form.mattress.value;
var ceiling = form.ceiling.value;
var above = form.above.value;
var leg691 = 0
var leg692 = 0
var leg831 = 0
var leg832 = 0
var trim691 = 0
var trim692 = 0
var trim831 = 0
var trim832 = 0
var underceiling = (ceiling - above - mattress - 3);

form.under691.value = (69 - 5 - mattress - 3);
if (underceiling < form.under691.value) (form.under691.value = underceiling);
form.under831.value = (83 - 5 - mattress - 3);
if (underceiling < form.under831.value) (form.under831.value = underceiling);
form.under692.value = (69 - 10 - mattress - 3);
if (underceiling < form.under692.value) (form.under692.value = underceiling);
form.under832.value = (83 - 10 - mattress - 3);
if (underceiling < form.under832.value) (form.under832.value = underceiling);

form.a691.value = (ceiling - mattress - 3 - form.under691.value);
form.a831.value = (ceiling - mattress - 3 - form.under831.value);
form.a692.value = (ceiling - mattress - 3 - form.under692.value);
form.a832.value = (ceiling - mattress - 3 - form.under832.value);

leg691 = -(-3 - mattress - 5 - form.under691.value);
leg831 = -(-3 - mattress - 5 - form.under831.value);
leg692 = -(-3 - mattress - 10 - form.under692.value);
leg832 = -(-3 - mattress - 10 - form.under832.value);

trim691 = 69 - leg691;
trim831 = 83 - leg831;
trim692 = 69 - leg692;
trim832 = 83 - leg832;

form.top691.value = leg691 - 5;
form.top831.value = leg831 - 5;
form.top692.value = leg692 - 10;
form.top832.value = leg832 - 10;

minabove30 = "Suggestion: We recommend the Minimum Headroom Above the Mattress is 30 inches.";
mattresszero = "Error: The Mattress Thickness must be greater than zero";
mattress40 = "Error: The Mattress Thickness must be less than 40 inches";

if (mattress < 1) alert(mattresszero); // mattress must be greater than zero
if (mattress > 40) alert(mattress40); // mattress can't be greater then 40
if (above < 10) alert(minabove30); // minimum headroom above is 30

}
// End -->
</script>

<center>
<form method="POST" id="calcform">


<table bgcolor="#ffffff" width="550" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td><h2>Height Calculator</h2>
<h4>How much headroom will I get?<br />
Enter your specifications below and then press Calculate Headroom. </h4></td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top">
<div>
<table width="85%" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="74%">Total Mattress Thickness <a href="#" class="hintanchor" onMouseOver="showhint('Enter the total thickness of the mattress and any mattress topper.', this, event, '200px')" style="text-decoration: none; vertical-align: middle; font-weight: 400;color:#900">[?]</a></td>
<td width="26%"><input name="mattress" size="3" value="8" onFocus="select()" maxlength="2"> inches</td>
</tr>
<tr>
<td>Ceiling Height <a href="#" class="hintanchor" onMouseOver="showhint('We need the ceiling height to calculate how much headroom you will get above and underneath.', this, event, '200px')" style="text-decoration: none; vertical-align: middle; font-weight: 400;;color:#900">[?]</a></td>
<td><input name="ceiling" size="3" value="96" onFocus="select()"> inches</td>
</tr>
<tr>
<td>Minimum Headroom Above Mattress <a href="#" class="hintanchor" onMouseOver="showhint('We recommend a minimum of 30 inches of headroom above.', this, event, '200px')" style="text-decoration: none; vertical-align: middle; font-weight: 400;;color:#900">[?]</a></td>
<td><input name="above" size="3" value="30" onFocus="select()"> inches</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="right"><input value="Reset" type="reset" onclick="setTimeout(function(){calc_headroom(document.getElementById('calcform'));}, 100); return true;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input value="Calculate Headroom" onClick="calc_headroom(this.form)" type="button"></td>
</tr>
</table><br /> <br />

<h2><strong><center>Headroom Above &amp; Underneath the Mattress</center></strong></h2><br />

<table width="75%" align="center" cellpadding="2" cellspacing="2">
<tr>
<td colspan="2"><strong>Using Single Or Double Safety Rail</strong></td>
</tr>
<tr>
<td><strong>69" Legs</strong></td>
<td><strong>83" Legs</strong></td>
</tr>
<tr>
<td>Above &nbsp;<input name="a691" value="32" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"></td>
<td>Above &nbsp;<input name="a831" value="18" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"></td>
</tr>
<tr>
<td>Underneath&nbsp;<input name="under691" value="53" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"></td>
<td>Underneath&nbsp;<input name="under831" value="67" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"></td>
</tr>
<tr>
<td>Top of Mattress&nbsp;<input name="top691" value="64" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"></td>
<td>Top of Mattress&nbsp;<input name="top831" value="78" size="3" style="color: rgb(255, 0, 0); font-weight: bold;"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr>
<td colspan="2" align="center"><input value="Return to Previous Page" onClick="javascript:history.back()" type="button"></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</table>

<center>
<p><img src="media/cms/html/loft_drawing_text.gif" width="485" border="0" height="339"></p>
<table width="100%" cellspacing="2" cellpadding="2">
<tr>
<td height="33%" align="center" valign="top"><h6>Standard 69" Legs<br />Single Safety Rail<br /><img src="media/cms/html/loft_clear_100x97.jpg" width="100" height="97" alt="Standard 69&quot; Legs with Single Safetry Rail"></h6></td>
<td height="33%" align="center" valign="top"><h6>Extra Tall 83" Legs<br />Single Safety Rail<br /><img src="media/cms/html/loft_extratall_100x111.jpg" width="100" height="111" alt="Extra Tall 83&quot; Legs with Single Safety Rail"></h6></td>
<td width="33%" align="center" valign="top"><h6>Standard 69" Legs<br />Youth (Double) Safety Rails<br /><img src="media/cms/html/youth_sdc_1468x1480_small1.jpg" width="100" height="100" alt="Standard 69&quot; Legs with Youth (Double) Safety Rails"></h6></td>
</tr>
</table>
<p>&nbsp;</p>
</center>


</div></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>

</form></center>
<script>
calc_headroom(document.getElementById('calcform'));
</script>

jscheuer1
10-18-2017, 04:30 PM
It was working fine for me. You changed something else. You removed elements from the form, and now the script is throwing an error when it looks for them. You should either put them back or we will need to remove them from the script. Also, this part has nothing to do with it:


<style type="text/css">

#hintbox{ /*CSS for pop up hint box */
position:absolute;
top: 0;
background-color: lightgrey;
width: 150px; /*Default width of hint.*/
padding: 3px;
border:1px solid black;
font:normal 12px Arial;
line-height:18px;
z-index:100;
border-right: 3px solid black;
border-bottom: 3px solid black;
visibility: hidden;
}

.hintanchor{ /*CSS for link that shows hint onmouseover*/
font-weight: bold;
color: navy;
margin: 3px 8px;
}

</style>

<script type="text/javascript">

/***********************************************
* Show Hint script- � Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox

</script>

That part is a hint script and is working fine. When you hover over the [?] symbols, it gives you hints. The other part here:


<script language="JavaScript">
<!-- Begin
function calc_headroom(form) {
var mattress = form.mattress.value;
var ceiling = form.ceiling.value;
var above = form.above.value;
var leg691 = 0
var leg692 = 0
var leg831 = 0
var leg832 = 0
var trim691 = 0
var trim692 = 0
var trim831 = 0
var trim832 = 0
var underceiling = (ceiling - above - mattress - 3);

form.under691.value = (69 - 5 - mattress - 3);
if (underceiling < form.under691.value) (form.under691.value = underceiling);
form.under831.value = (83 - 5 - mattress - 3);
if (underceiling < form.under831.value) (form.under831.value = underceiling);
form.under692.value = (69 - 10 - mattress - 3);
if (underceiling < form.under692.value) (form.under692.value = underceiling);
form.under832.value = (83 - 10 - mattress - 3);
if (underceiling < form.under832.value) (form.under832.value = underceiling);

form.a691.value = (ceiling - mattress - 3 - form.under691.value);
form.a831.value = (ceiling - mattress - 3 - form.under831.value);
form.a692.value = (ceiling - mattress - 3 - form.under692.value);
form.a832.value = (ceiling - mattress - 3 - form.under832.value);

leg691 = -(-3 - mattress - 5 - form.under691.value);
leg831 = -(-3 - mattress - 5 - form.under831.value);
leg692 = -(-3 - mattress - 10 - form.under692.value);
leg832 = -(-3 - mattress - 10 - form.under832.value);

trim691 = 69 - leg691;
trim831 = 83 - leg831;
trim692 = 69 - leg692;
trim832 = 83 - leg832;

form.top691.value = leg691 - 5;
form.top831.value = leg831 - 5;
form.top692.value = leg692 - 10;
form.top832.value = leg832 - 10;

minabove30 = "Suggestion: We recommend the Minimum Headroom Above the Mattress is 30 inches.";
mattresszero = "Error: The Mattress Thickness must be greater than zero";
mattress40 = "Error: The Mattress Thickness must be less than 40 inches";

if (mattress < 1) alert(mattresszero); // mattress must be greater than zero
if (mattress > 40) alert(mattress40); // mattress can't be greater then 40
if (above < 10) alert(minabove30); // minimum headroom above is 30

}
// End -->
</script>

Is the only javascript which deals with calculating. That and the form are all that's involved. None of it's from Dynamic Drive.

jonaha
10-18-2017, 07:34 PM
Can I pay to make a script do what I want it to do based on this page?

https://www.nationalhomestore.com/ste_heightcalculator

jscheuer1
10-19-2017, 12:04 AM
Sure. But again, I don't think you really need to. I probably should have noted before that I don't like having to hit a moving target. If that's how you want the page, I can get it working. If it's not, please make sure the page is as you want it before asking for further help.

jscheuer1
10-19-2017, 02:06 PM
Sure. But again, I don't think you really need to. I probably should have noted before that I don't like having to hit a moving target. If that's how you want the page, I can get it working. If it's not, please make sure the page is as you want it before asking for further help.

Something else occurred to me about this situation. Since we already had it working, then you removed form elements which then broke it again, you could just put those back and it would work. If you don't want those shown, you can just set them to display none. That way, if you ever wanted to bring them back, you could, and it wouldn't break the script. You could also remove others and bring these back, or a combination. A much better idea than having to fix the script every time you change the form. If you need help on making your form elements display none, just let me know.

jonaha
10-19-2017, 03:16 PM
Hi John,
I just put back the original script with your changes and it does not calculated correctly in all the fields. It need to change the bottom part by the same amount that is entered above. For example, if you increase the mattress thickness by 2" you decrease the clearance height and under bed clearance by the same amount.

https://www.nationalhomestore.com/ste_heightcalculator

jscheuer1
10-20-2017, 12:50 AM
OK, I'm not sure what you mean. I agree that if you change a value in the top part, it doesn't automatically change the values in the bottom part. However, if after you change a value in the top part, you hit the "Calculate Headroom" button, then the values in the bottom do change in a way that makes sense to me. So, either you want them to change immediately, or you want them to change in a different way, or both (any or all of which can be arranged, if I only know for certain what you are after). Can you be more specific about exactly what you wish to see happen?

On the other hand, if you are not seeing any changes in the bottom part after changes in the top part and hitting the "Calculate Headroom" button, then perhaps you need to clear the cache and/or refresh the page. And if after that you're still not seeing any changes in the bottom part, let me know which browser and which version of that browser you are using because in any modern browser, it should be working at least as I'm seeing it.

That said, again, if it is working like I say I'm seeing when you test it, but that's still not what you want, please be more specific about the result you desire.

jonaha
10-23-2017, 06:46 PM
Hi,
All it needs to do is change the bottom values by the same amount as it is changed on top. For example, if you increase the ceiling height by 2" so should the value on the bottom be increased by 2". If you increase the tickness of the mattress by 2" then the clearance on the bottom is reduced by 2". I hope this helps.

jscheuer1
10-25-2017, 06:54 PM
As far as I can tell that's what happens. For example, if I increase mattress size from 8 to 10 and then click "Calculate Headroom", the "Underneath" values in all four lower sections decrease by 2. You really need to be more specific about what the problems is, if in fact there really is one.

jonaha
10-25-2017, 06:55 PM
Any way I can get a script to work the way I want it to?

jscheuer1
10-25-2017, 07:04 PM
Yes, if you explain clearly how it's not already doing that. Use my example, and explain what you would rather see happen in that case.

jonaha
10-26-2017, 03:22 PM
Total Mattress Thickness [?]
8 (If this increases then the under bed clearance is reduced by the same amount)
inches
Ceiling Height [?]
96 (If this increases then the above clearance is increased by the same amount)
inches
Minimum Headroom Above Mattress [?]
30(If this increases then the above clearance is increased by the same amount)
inches


Headroom Above & Underneath the Mattress

Using Single Or Double Safety Rail
69" Legs 83" Legs
Above
32
Above
18
Underneath
53
Underneath
67
Top of Mattress
64
Top of Mattress
78

Please see this page on the starting off sizes and layout. https://www.nationalfurnishing.com/cgi-bin/ccp51/cp-app.cgi?usr=51J9089480&rnd=9025379&rrc=N&affl=&cip=68.198.3.104&act=&aff=&pg=ste_heightcalculator

styxlawyer
10-26-2017, 05:10 PM
Any way I can get a script to work the way I want it to?

As John has written several times, you need to much more specific about what it is that doesn't work for you, as it seems to work OK for all of us.

jscheuer1
10-26-2017, 08:15 PM
This page is still working:

https://www.nationalhomestore.com/ste_heightcalculator

The page you just posted does not, but that's because you took away some of the receiving elements from the form. If you want it to look like that, it can, and still work. But instead of removing the elements you don't want showing, instead just make them display none. Do you know how to do that? If not, I can show you how.

jscheuer1
10-26-2017, 08:27 PM
Here's a demo:

http://jscheuer1.com/demos/tidbits/form_calc-2-h.htm

Is that what you're looking for?

jonaha
10-26-2017, 09:09 PM
Yes, Thank you. But for the 83" height leg the default heights above should be 18", under 67" and top of the mattress 78". Otherwise it looks good.


Regards,
Jonah

jscheuer1
10-26-2017, 10:32 PM
Can't have a default height above of 18 when the min height above is 30. Also, with only 18 inches above (more like 10 if you count the size of the person's head), I'd feel like a sardine.

jonaha
10-26-2017, 11:13 PM
Ok, I got you. Can you change the other defaults and send me the script?

jonaha
10-29-2017, 03:00 PM
I copied the code but I can not change the defaults and the css seems to be off. Can you help?

https://www.nationalhomestore.com/ste_heightcalculator

jscheuer1
10-29-2017, 07:17 PM
Well, I don't see an issue with the css, can you be more specific? As for the defaults, they're easy to change (done right in the form), but I really don't see 18'' as a realistic clearance above the mattress. After all, the average head from back to forehead is about 8". Unless that's accounted for, that leaves only 10" above the person's head. Ouch, if you catch my meaning. Even if the 8" is accounted for, it seems awfully tight.

Anyways, though I don't recommend it, and not for coding reasons, simply because it seems too small of a space to sleep in, I've put up a demo with the 18" default min head room:

http://jscheuer1.com/demos/tidbits/form_calc-3-h.htm

jonaha
10-30-2017, 05:09 PM
Hi,
Thank you very much for the help. It is working very well now.
FYI, people that purchase the extra tall bed usually have a ceiling that is more then 8'.

Regards,
Jonah