Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Could really do with a hand

    Hi,

    I've really tried to work this out but I can't.. I've read up on variable functions but can't get the link right.

    I place a variable in the beginning of the JS such as:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <SCRIPT LANGUAGE="JavaScript">

    <!-- Begin

    var mx="5.73";

    function doMath(s) {
    var form = document.getElementsByName(s)[0];
    var one = parseFloat(form.con1.value);
    var two = parseFloat(form.cable.value);
    var three = parseFloat(form.length.value);
    var four = parseFloat(form.con2.value);
    var five = 0.0;
    if (form.con3) {
    five = parseFloat(form.con3.value);
    }
    var prod = (two * three) + one + four + five;

    form.amount.value=custRound(prod,3);
    }

    function custRound(x,places) {
    return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
    }

    // End -->

    But I can't get it to control the HTML. What I have in there is:

    <select name="con1">
    <option value="createElement('mx')"selected>Male XLR</option>
    <option value="6.26">Female XLR</option>
    <option value="6.83">Stereo Jack (TRS)</option>
    <option value="5.70">Mono Jack</option>
    <option value="4.05">Phono (RCA)</option>
    <option value="4.05">Minijack</option>


    Please give me a clue to what I'm doing wrong. I tried to figure it out but have failed..

    Thanks in advance

    Anto

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did you look at my response to your last post about this question?

    Another JS calcutation question..

    david_kw

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Never saw that until now.. Thank you so much!! I was pulling my hair out. I'll have a look to see if I can understand it..

    Thank you again

    Anto


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •