Jump to content
Note to New Members ×

html gurus


Donek

Recommended Posts

I'm working on updating the web site and had an idea that someone might be able to help with. As we offer customization, I thought I'd forgo the waist width on some of the spec sheets and let people enter their desired width. As the math is really simple to calculate the tip and tail widths, it would be nice for that data to simply populate. Is there someone out there who knows enough html and java to make that happen. Here's a sample of the document.

<table width="300" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666">

<tr>

<td width="38">Length</td>

<td width="34">Edge</td>

<td width="110">SC (m)</td>

<td width="34">N</td>

<td width="34">W</td>

<td width="34">T</td>

<td width="38">Price</td>

</tr>

<tr>

<td class="style5">170</td>

<td class="style5">133</td>

<td class="style5">10-12</td>

<td class="style5">W+4.8</td>

<td class="style5">any</td>

<td class="style5">W+3.3</td>

<td class="style5">780</td>

</tr>

<tr>

<td class="style5">175</td>

<td class="style5">138</td>

<td class="style5">10.3-12.3</td>

<td class="style5">W+5.0</td>

<td class="style5">any</td>

<td class="style5">W+3.5</td>

<td class="style5">780</td>

</tr>

<tr>

<td class="style5">180</td>

<td class="style5">143</td>

<td class="style5">10.7-12.7</td>

<td class="style5">W+5.1</td>

<td class="style5">any</td>

<td class="style5">W+3.6</td>

<td class="style5">780</td>

</tr>

<tr>

<td class="style5">185</td>

<td class="style5">148</td>

<td class="style5">11-13</td>

<td class="style5">W+5.3</td>

<td class="style5">any</td>

<td class="style5">W+3.8</td>

<td class="style5">780</td>

</tr>

<tr>

<td class="style5">190</td>

<td class="style5">152</td>

<td class="style5">11.3-13.3</td>

<td class="style5">W+5.5</td>

<td class="style5">any</td>

<td class="style5">W+4.0</td>

<td class="style5">780</td>

</tr>

<tr>

<td class="style5"><span class="style5">195 </span></td>

<td class="style5"><span class="style5">157 </span></td>

<td class="style5">11.7-13.7</td>

<td class="style5">W+5.7</td>

<td class="style5">any</td>

<td class="style5">W+4.2</td>

<td class="style5">780</td>

</tr>

<tr>

<td class="style5">200</td>

<td class="style5"><span class="style5">163 </span></td>

<td class="style5">12-14</td>

<td class="style5">W+5.9</td>

<td class="style5">any</td>

<td class="style5">W+4.3</td>

<td class="style5">780</td>

</tr>

<tr>

<td class="style5"><span class="style5">205 </span></td>

<td class="style5">168</td>

<td class="style5">12.3-14.3</td>

<td class="style5">W+6.1</td>

<td class="style5">any</td>

<td class="style5">W+4.5</td>

<td class="style5">780</td>

</tr>

<tr>

<td class="style5"><span class="style5">210 </span></td>

<td class="style5">173</td>

<td class="style5">12.7-14.7</td>

<td class="style5">W+6.2</td>

<td class="style5">any</td>

<td class="style5">W+4.7</td>

<td class="style5">780</td>

</tr>

</table>

If it was possible to enter a waist width on the page somewhere and populate the data, that would be pretty cool.

Link to comment
Share on other sites

Sean,

You can do the calculation and changing the text with some javascript like this. Setting the innerHTML is what is changing the text based on the input and the math calculations.

<script type="text/javascript">
function donek(id, nose, tail){
var userInput = document.getElementById(id).value;
var length = id.substring(5);
document.getElementById('nose'+length).innerHTML = parseFloat(userInput) + parseFloat(nose);
document.getElementById('tail'+length).innerHTML = parseFloat(userInput) + parseFloat(tail);
return (false);
}
</script>

And the HTML would be something like this (I just edited your first row). I placed an input button in a cell at the end of the row. When clicked, it calls the javascript function, passing the element ID to get the data from, and the values for the nose and tail calculation, since they were different depending on the length of the board.

<form id="test" name="test">
<table width="300" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666"><br />
     <tr><br />
       <td width="38">Length</td><br />
       <td width="34">Edge</td><br />
       <td width="110">SC (m)</td><br />
       <td width="34">N</td><br />
       <td width="34">W</td><br />
       <td width="34">T</td><br />
       <td width="38">Price</td><br />
       <td/>
     </tr><br />
     <tr><br />
       <td class="style5">170</td><br />
       <td class="style5">133</td><br />
       <td class="style5">10-12</td><br />
       <td class="style5" id="nose170"></td><br />
       <td class="style5"><input type="text" id="waist170" value="Enter Waist Size"/></td><br />
       <td class="style5" id="tail170"></td><br />
       <td class="style5">780</td><br />
       <td class="style5"><input type="button" onClick="return donek('waist170','4.8', '3.3');" value="Get Measurements"/></td>
     </tr><br />
</table></form>

This was a pretty simple way to do it. You can get fancy by having one input text box and one button that on clicking will go through all the IDs in this table, and calculate everything and replace them with the single user's input. It would be setting up to be able to get a list of these in the javascript to iterate through and do the calculations.

Let me know if you have any questions.

Khanh

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...