Calling Javascript Functions

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default Calling Javascript Functions

    Hi,

    I've done a function to populate a drop down list, but I cant seem to call it
    properly.

    ==================
    This is in the head of the document:
    <script language="JavaScript">
    function addAge(){
    var optionNum = 0+2;
    for (var i = 1; i <= 100; i++) {
    document.personalDetails.day.options[optionNum] = new Option(i, i);
    optionNum++;
    }
    }
    </script>
    ================================
    I then call the function on the form page like this:
    <script language="JavaScript">
    addAge( );
    </script>

    Hope you can help.



    Mattastic Guest

  2. Similar Questions and Discussions

    1. Calling other functions
      All, Using .NET 1.1, I have built a custom control, however I am having trouble compiling it. For the on click event of the button, I want it to...
    2. calling javascript dom functions from a flash objectwith frames
      Calling dom javascript functions from a flash object works properly in a regular web page. When this page is a part of a frameset on another...
    3. Calling functions between frames...
      JavaScript can not run on server side. You can include it in the output of your PHP script. "Albert Finchly" <Albert_Finchly@Yahoo.co.uk>...
    4. Calling functions?
      Hello, I wrote a jscript function within the HTML window of my webpage and would like to call it from inside the ASPX code-behind page. Any...
    5. calling functions
      how do i call a vbscript function (which is between <%%>) from a vbscript script function (which is between script tags-<script...
  3. #2

    Default Re: Calling Javascript Functions

    Please, send your completly code ?

    --
    ________________________________________
    João Cândido de Souza Neto
    Consultor Web
    Idealizador e Instrutor do curso de Web Developer na Microlins Varginha

    A inteligência não substitui a falta de informação.

    "Mattastic" <webforumsuser@macromedia.com> wrote in message
    news:ch7a77$97u$1@forums.macromedia.com...
    > Hi,
    >
    > I've done a function to populate a drop down list, but I cant seem to
    call it
    > properly.
    >
    > ==================
    > This is in the head of the document:
    > <script language="JavaScript">
    > function addAge(){
    > var optionNum = 0+2;
    > for (var i = 1; i <= 100; i++) {
    > document.personalDetails.day.options[optionNum] = new Option(i, i);
    > optionNum++;
    > }
    > }
    > </script>
    > ================================
    > I then call the function on the form page like this:
    > <script language="JavaScript">
    > addAge( );
    > </script>
    >
    > Hope you can help.
    >
    >
    >

    João Cândido de Souza Neto Guest

  4. #3

    Default Re: Calling Javascript Functions

    Ok Thanks, here is the code

    ====
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    body {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    }
    textarea, input {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 84%;
    }
    td {
    vertical-align: top;
    font-size: 84%;
    }
    table {
    border: none;
    margin: 3px;
    padding: 3px;
    }

    -->
    </style>

    <script language="JavaScript">
    function addAge(){
    var optionNum = 2;
    //adds age
    for (var i = 1; i <= 100; i++) {
    document.personalDetails.day.options[optionNum] = new Option(i, i);
    optionNum++;
    }
    }

    </script>
    </head>
    <body >


    <table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td>



    Please complete this form clearly and accurately,
    click next when each section is complete.1

    <script language="JavaScript">
    addAge( );
    </script>


    <form name="personalDetails" method="post" action="">

    <table width="760" border="0" align="center" cellpadding="5" cellspacing="0">
    <tr>
    <td width="50%" valign="top"><strong>Personnel Details</strong><br>
    <br>
    <table border=0 align="center" cellpadding=3 cellspacing=0>
    <tr>
    <td>&nbsp;</td>
    <td class=bldturq11 valign=bottom>surname</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input name="sName" type="text" value="" class=input1col
    maxlength=40></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td class=bldturq11 valign=bottom>first name</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input name="fName" type="text" value="" class=input1col
    maxlength=40></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td class=bldturq11 valign=bottom>date of birth - dd mm yyyy</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><table width=144 cellspacing=0 cellpadding=0 border=0>
    <tr>
    <td width="38" class=inputdate1><select name="day">

    </select></td>
    <td width="38" class=inputdate1><input name="dobMM"
    type="text" value="" size=3 class=inputdate1 maxlength=2></td>
    <td width="68" class=inputdate2><input name="dobYYYY"
    type="text" value="" size=5 class=inputdate2 maxlength=4></td>
    </tr>
    </table></td>
    </tr>
    </table>
    </td>
    <td width="50%">
    <table border=0 align="center" cellpadding=3 cellspacing=0>
    <tr>
    <td height="20" >&nbsp;</td>
    <td width="200" valign=bottom class=bldturq11>Address</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input name="email" type="text" value="" class=input1col
    maxlength=40></td>
    </tr>
    <tr>
    <td height="31">&nbsp;</td>
    <td><input name="houseName" type="text" value="" class=input1col
    maxlength=40></td>
    </tr>
    <tr>
    <td class=sp22>&nbsp;</td>
    <td class=bldturq11 valign=bottom>Town</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input name="postCode" type="text" value="" class=input1col
    maxlength=8></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td colspan=3 class=bldturq11 valign=bottom>Post Code</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td class=input1col><input name="registration" type="text" size=24
    class=input1col value="" maxlength=10 ></td>
    </tr>
    <tr>
    <td class=sp22>&nbsp;</td>
    <td td colspan=3 class=bldturq11 valign=bottom>Phone - home</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td class=select1col> <input name="registration2" type="text"
    size=24 class=input1col value="" maxlength=10 >
    </td>
    </tr> <tr>
    <td>&nbsp;</td>
    <td class=select1col> Mobile</td>
    </tr> <tr>
    <td>&nbsp;</td>
    <td class=select1col> <input name="registration22" type="text"
    size=24 class=input1col value="" maxlength=10
    onchange="document.theForm.action.value=''"></td>
    </tr><tr>
    <td>&nbsp;</td>
    <td class=select1col> Email</td>
    </tr><tr>
    <td>&nbsp;</td>
    <td class=select1col> <input name="registration22" type="text"
    size=24 class=input1col value="" maxlength=10
    onchange="document.theForm.action.value=''"></td>
    </tr>
    </table>
    </td>
    </tr>
    </table></form>
    </td>
    </tr>
    </table>
    <table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td height="20"></td>
    <td><div align="right">
    <a href="index.cfm?page=next&count=1"><img src="images/next.gif"
    border="0"></a>
    </div></td>
    </tr>
    </table>
    </body>
    </html>
    ===========================

    Mattastic Guest

  5. #4

    Default Re: Calling Javascript Functions

    Call the addage function after the definition day select.

    --
    ________________________________________
    João Cândido de Souza Neto
    Consultor Web
    Idealizador e Instrutor do curso de Web Developer na Microlins Varginha

    A inteligência não substitui a falta de informação.

    "Mattastic" <webforumsuser@macromedia.com> wrote in message
    news:ch7c3a$bt1$1@forums.macromedia.com...
    > Ok Thanks, here is the code
    >
    > ====
    > <html>
    > <head>
    > <title>Untitled Document</title>
    > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    > <style type="text/css">
    > <!--
    > body {
    > font-family: Verdana, Arial, Helvetica, sans-serif;
    > }
    > textarea, input {
    > font-family: Verdana, Arial, Helvetica, sans-serif;
    > font-size: 84%;
    > }
    > td {
    > vertical-align: top;
    > font-size: 84%;
    > }
    > table {
    > border: none;
    > margin: 3px;
    > padding: 3px;
    > }
    >
    > -->
    > </style>
    >
    > <script language="JavaScript">
    > function addAge(){
    > var optionNum = 2;
    > //adds age
    > for (var i = 1; i <= 100; i++) {
    > document.personalDetails.day.options[optionNum] = new Option(i, i);
    > optionNum++;
    > }
    > }
    >
    > </script>
    > </head>
    > <body >
    >
    >
    > <table width="760" border="0" align="center" cellpadding="0"
    cellspacing="0">
    > <tr>
    > <td>
    >
    >
    >
    > Please complete this form clearly and accurately,
    > click next when each section is complete.1
    >
    > <script language="JavaScript">
    > addAge( );
    > </script>
    >
    >
    > <form name="personalDetails" method="post" action="">
    >
    > <table width="760" border="0" align="center" cellpadding="5"
    cellspacing="0">
    > <tr>
    > <td width="50%" valign="top"><strong>Personnel Details</strong><br>
    > <br>
    > <table border=0 align="center" cellpadding=3 cellspacing=0>
    > <tr>
    > <td>&nbsp;</td>
    > <td class=bldturq11 valign=bottom>surname</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td><input name="sName" type="text" value="" class=input1col
    > maxlength=40></td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td class=bldturq11 valign=bottom>first name</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td><input name="fName" type="text" value="" class=input1col
    > maxlength=40></td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td class=bldturq11 valign=bottom>date of birth - dd mm
    yyyy</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td><table width=144 cellspacing=0 cellpadding=0 border=0>
    > <tr>
    > <td width="38" class=inputdate1><select name="day">
    >
    > </select></td>
    > <td width="38" class=inputdate1><input name="dobMM"
    > type="text" value="" size=3 class=inputdate1 maxlength=2></td>
    > <td width="68" class=inputdate2><input name="dobYYYY"
    > type="text" value="" size=5 class=inputdate2 maxlength=4></td>
    > </tr>
    > </table></td>
    > </tr>
    > </table>
    > </td>
    > <td width="50%">
    > <table border=0 align="center" cellpadding=3 cellspacing=0>
    > <tr>
    > <td height="20" >&nbsp;</td>
    > <td width="200" valign=bottom class=bldturq11>Address</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td><input name="email" type="text" value="" class=input1col
    > maxlength=40></td>
    > </tr>
    > <tr>
    > <td height="31">&nbsp;</td>
    > <td><input name="houseName" type="text" value=""
    class=input1col
    > maxlength=40></td>
    > </tr>
    > <tr>
    > <td class=sp22>&nbsp;</td>
    > <td class=bldturq11 valign=bottom>Town</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td><input name="postCode" type="text" value="" class=input1col
    > maxlength=8></td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td colspan=3 class=bldturq11 valign=bottom>Post Code</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td class=input1col><input name="registration" type="text"
    size=24
    > class=input1col value="" maxlength=10 ></td>
    > </tr>
    > <tr>
    > <td class=sp22>&nbsp;</td>
    > <td td colspan=3 class=bldturq11 valign=bottom>Phone -
    home</td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td class=select1col> <input name="registration2" type="text"
    > size=24 class=input1col value="" maxlength=10 >
    > </td>
    > </tr> <tr>
    > <td>&nbsp;</td>
    > <td class=select1col> Mobile</td>
    > </tr> <tr>
    > <td>&nbsp;</td>
    > <td class=select1col> <input name="registration22" type="text"
    > size=24 class=input1col value="" maxlength=10
    > onchange="document.theForm.action.value=''"></td>
    > </tr><tr>
    > <td>&nbsp;</td>
    > <td class=select1col> Email</td>
    > </tr><tr>
    > <td>&nbsp;</td>
    > <td class=select1col> <input name="registration22" type="text"
    > size=24 class=input1col value="" maxlength=10
    > onchange="document.theForm.action.value=''"></td>
    > </tr>
    > </table>
    > </td>
    > </tr>
    > </table></form>
    > </td>
    > </tr>
    > </table>
    > <table width="760" border="0" align="center" cellpadding="0"
    cellspacing="0">
    > <tr>
    > <td height="20"></td>
    > <td><div align="right">
    > <a href="index.cfm?page=next&count=1"><img
    src="images/next.gif"
    > border="0"></a>
    > </div></td>
    > </tr>
    > </table>
    > </body>
    > </html>
    > ===========================
    >

    João Cândido de Souza Neto Guest

  6. #5

    Default Re: Calling Javascript Functions

    Thanks very much
    Mattastic Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139