beginners question

Discussion in 'Javascript' started by dirk, Sep 9, 2005.

  1. dirk

    dirk Guest

    i gave made some code in VBA for Excel.
    i want to make a webpage with the same examples as my excel file, so i think
    i will need javascript (serverside?)
    how do i begin?
    are there some good sites?
    dirk, Sep 9, 2005
    1. Advertisements

  2. dirk

    Dag Sunde Guest

    Are we to understand that you want a web page that shows/execute
    som mathematical calculations based on some user input?

    You can do this serverside in any language supported by your
    webserver by posting the form with the input-values back to
    your server-script, let it do the calculations and generate
    the result page back to the browser.

    If you do it serverside I suggest using IIS, since you obviously
    are familiar with VBA witch are very close to VBScript. ASP pages
    can be coded in VB-Script.

    Or... You can choos to write all your calculations in JavaScript
    as functions in the web-page itself, and do all of the work in
    the users browser (clientside).

    If you choose the last alternative (I would), then this is the
    right NG to ask.
    Dag Sunde, Sep 9, 2005
    1. Advertisements

  3. dirk

    dirk Guest

    so yes,
    i want to do it by using javascript (client side)
    what do you mean by "the right NG to ask"?

    can you give me some examples for writing an inputbox and a commandbutton on
    a html page,
    then returning the value of this inputbox by deviding it by 3 for example?

    are there some good sites where i can study this?
    thank you
    dirk, Sep 12, 2005
  4. dirk

    Dag Sunde Guest

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    <html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript">
    function divideBy3() {
    var myNum = document.getElementById("myNumber").value;
    var myResult = document.getElementById("result");
    myResult.value = myNum / 3;
    return true

    <label>Number to divide: </label>
    <input type="text" id="myNumber" value="" />&nbsp;
    <input type="button" id="cmdDivide" value="Divide by 3"
    onclick="divideBy3();"/><br />
    <label>Result: </label>
    <input type="text" id="result" value="" />

    Dag Sunde, Sep 12, 2005
  5. dirk

    ASM Guest

    <form name="form_1">
    <p>Enter a number here :
    <input type=text onchange="result.value=this.value/3">
    and click outside (on page)
    <input type=text name="result">
    <p>number 1 :
    <input type=text name="num1" size=5>
    <select name="choiss">
    <option> +
    <option> -
    <option> :
    <option> x
    number 2 :
    <input type=text name="num2" size=5>
    <input type=button value="calcul" onclick="calc()">
    <input type=text name="total" size=6>
    <script type="text/javascript">
    function calc() {
    var f = document.forms['form_1'];
    var n1 = f.num1.value;
    var n2 = f.num2.value;
    var op = new Array('','+','-','/','*');
    var i = f.choiss.selectedIndex;
    if(i==0) alert('you din\'t select an operator');
    else eval(n1+op+n2);
    ASM, Sep 12, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.