'Value' is null or not is object.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • viki1967
    Contributor
    • Oct 2007
    • 263

    #16
    This code is correct.

    But with the same function javascript calcola, I could get together:

    In the form:

    The input type="text" "TotaleCompeten zeExtra-1" = "CompetenzeExtr a-1" +
    "CompetenzeExtr a-2" +
    "CompetenzeExtr a-3"

    The input type="text" "TotaleCompeten zeExtra-2" = 0.00 Always No change
    The input type="text" "TotaleCompeten zeExtra-3" = 0.00 Always No change

    AND

    The input type="text" "TotaleTrattenu teExtra-1" = "TrattenuteExtr a-1" +
    "TrattenuteExtr a-2" +
    "TrattenuteExtr a-3"

    The input type="text" "TotaleTrattenu teExtra-2" = 0.00 Always No change
    The input type="text" "TotaleTrattenu teExtra-3" = 0.00 Always No change


    It's possible?

    Many Thanks,
    Viki1967

    Comment

    • Ferris
      New Member
      • Oct 2007
      • 101

      #17
      OK

      [CODE=javascript]
      <script language="javas cript" type="text/javascript">
      <!--
      function calcola(frmObj, id)
      {
      frmObj["CompetenzeExtr a-" + id].value = parseFloat(frmO bj["ImportoBas e-" + id].value) * parseFloat(frmO bj["NumeroOre-" + id].value);
      frmObj["CompetenzeExtr a-" + id].value = parseFloat(frmO bj["CompetenzeExtr a-" + id].value).toFixed (2);
      frmObj["TrattenuteExtr a-" + id].value = parseFloat(frmO bj["ImportoBaseTra ttenute-" + id].value) * parseFloat(frmO bj["NumeroOreTratt enute-" + id].value);
      frmObj["TrattenuteExtr a-" + id].value = parseFloat(frmO bj["TrattenuteExtr a-" + id].value).toFixed (2);
      var output = frmObj["TotaleCompeten zeExtra-" + 1];
      var output2 = frmObj["TotaleTrattenu teExtra-" + 1]
      if (output && output2){
      output.value = 0;
      output2.value = 0;
      for ( var n = 1 ; n <= 10 ; n++ )
      {
      var text = frmObj["CompetenzeExtr a-" + n];
      var text2 = frmObj["TrattenuteExtr a-"+n]
      if (text && text2){
      var x;
      x = parseFloat(text .value);
      output.value = parseFloat(outp ut.value) + ((isNaN(x)) ? 0 : x);
      x = parseFloat(text 2.value);
      output2.value = parseFloat(outp ut2.value) + ((isNaN(x)) ? 0 : x);
      }
      }
      output.value = parseFloat(outp ut.value).toFix ed(2);
      output2.value = parseFloat(outp ut2.value).toFi xed(2);
      }
      }
      -->
      </script>
      [/CODE]

      Comment

      • viki1967
        Contributor
        • Oct 2007
        • 263

        #18
        Your sincerely.

        Kind regards
        Viki1967

        Comment

        • viki1967
          Contributor
          • Oct 2007
          • 263

          #19
          Sorry....

          This code not working:



          : (

          Comment

          • viki1967
            Contributor
            • Oct 2007
            • 263

            #20
            Hi.

            The problem:

            It works if the dynamic form, assigns value ID = 1 to the input type = "text" "TotaleCompeten zeExtra-x."

            If value ID <> 1 in the input type = "text" "TotaleCompeten zeExtra-x" not working.

            The dynamic form is populated from database ID, then = 1
            but also different from 1...

            Comment

            • Ferris
              New Member
              • Oct 2007
              • 101

              #21
              Originally posted by viki1967
              Hi.
              The problem:
              It works if the dynamic form, assigns value ID = 1 to the input type = "text" "TotaleCompeten zeExtra-x."
              If value ID <> 1 in the input type = "text" "TotaleCompeten zeExtra-x" not working.
              The dynamic form is populated from database ID, then = 1
              but also different from 1...

              OK.
              1st: add the code under <title>.

              [HTML]
              <title>Modifica </title>
              <script language="javas cript" type="text/javascript">
              <!--
              var outID = 1;
              -->
              </script>
              [/HTML]

              The outID is the form ID that you want to output. Of cause,you may need use ASP etc. to write out these code.
              [HTML]
              <title>Modifica </title>
              <script language="javas cript" type="text/javascript">
              <!--
              var outID = <%=MySQL_ID%> ;
              -->
              </script>
              [/HTML]


              2st: change
              [CODE=javascript]
              var output = frmObj["TotaleCompeten zeExtra-" + 1];
              var output2 = frmObj["TotaleTrattenu teExtra-" + 1];
              [/CODE]


              into

              [CODE=javascript]
              var output = frmObj["TotaleCompeten zeExtra-" + outID];
              var output2 = frmObj["TotaleTrattenu teExtra-" + outID];
              [/CODE]

              Comment

              • viki1967
                Contributor
                • Oct 2007
                • 263

                #22
                Sintax error:

                [html]
                <html>
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
                <title>Modifica </title>
                <script language="javas cript" type="text/javascript">
                <!--

                var outID = <%=Rs("ID")%> ; <<<<<< Sintax error

                //-->
                </script>


                <script language="javas cript" type="text/javascript">

                <!--
                function calcola(frmObj, id)
                {
                frmObj["CompetenzeExtr a-" + id].value = parseFloat(frmO bj["ImportoBas e-" + id].value) * parseFloat(frmO bj["NumeroOre-" + id].value);
                frmObj["CompetenzeExtr a-" + id].value = parseFloat(frmO bj["CompetenzeExtr a-" + id].value).toFixed (2);
                frmObj["TrattenuteExtr a-" + id].value = parseFloat(frmO bj["ImportoBaseTra ttenute-" + id].value) * parseFloat(frmO bj["NumeroOreTratt enute-" + id].value);
                frmObj["TrattenuteExtr a-" + id].value = parseFloat(frmO bj["TrattenuteExtr a-" + id].value).toFixed (2);

                var output = frmObj["TotaleCompeten zeExtra-" + outID];
                var output2 = frmObj["TotaleTrattenu teExtra-" + outID];
                if (output && output2){
                output.value = 0;
                output2.value = 0;
                for ( var n = 1 ; n <= 10 ; n++ )
                {
                var text = frmObj["CompetenzeExtr a-" + n];
                var text2 = frmObj["TrattenuteExtr a-"+ n];
                if (text && text2){
                var x;
                x = parseFloat(text .value);
                output.value = parseFloat(outp ut.value) + ((isNaN(x)) ? 0 : x);
                x = parseFloat(text 2.value);
                output2.value = parseFloat(outp ut2.value) + ((isNaN(x)) ? 0 : x);
                }
                }
                output.value = parseFloat(outp ut.value).toFix ed(2);
                output2.value = parseFloat(outp ut2.value).toFi xed(2);
                }


                //chiusura function calcola
                }

                //-->
                </script>

                </head>
                <body>
                <form method="POST" name="frm">
                <p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
                <div align="center">
                <table border="0" id="table3">
                <tr>
                <td CLASS='MARGIN'> Importo<br>base </td>
                <td CLASS='MARGIN'> Numero<br>ore</td>
                <td CLASS='MARGIN'> Competenze<br>e xtra</td>

                <td CLASS='MARGIN'> Totale<br>Compe tenze extra</td>

                <td CLASS='MARGIN'> Importo<br>base </td>
                <td CLASS='MARGIN'> Numero<br>ore</td>
                <td CLASS='MARGIN'> Trattenute<br>e xtra</td>
                <td CLASS='MARGIN'> Totale<br>Tratt enute extra</td>
                </tr>
                <tr>
                <td><input type="text" name="ImportoBa se-1" size="5" value="8.38647" onKeyUp="calcol a(this.form, 1)"></td>
                <td><input type="text" name="NumeroOre-1" size="10" value="29" onKeyUp="calcol a(this.form, 1)"></td>
                <td><input type="text" name="Competenz eExtra-1" size="10" value="243.21" readonly style="backgrou nd-color: #C0C0C0" onKeyUp="calcol a(this.form, 1)"></td>
                <td><input type="text" name="TotaleCom petenzeExtra-1" size="10" value="421.26" readonly style="backgrou nd-color: #C0C0C0"></td>

                <td><input type="text" name="ImportoBa seTrattenute-1" size="5" value="100" onKeyUp="calcol a(this.form, 1)"></td>
                <td><input type="text" name="NumeroOre Trattenute-1" size="10" value="1" onKeyUp="calcol a(this.form, 1)"></td>
                <td><input type="text" name="Trattenut eExtra-1" size="10" value="100" readonly style="backgrou nd-color: #C0C0C0" onKeyUp="calcol a(this.form, 1)"></td>
                <td><input type="text" name="TotaleTra ttenuteExtra-1" size="10" value="100" readonly style="backgrou nd-color: #C0C0C0"></td>
                </tr>
                <tr>
                <td><input type="text" name="ImportoBa se-3" size="5" value="8.38647" onKeyUp="calcol a(this.form, 3)"></td>
                <td><input type="text" name="NumeroOre-3" size="10" value="8" onKeyUp="calcol a(this.form, 3)"></td>
                <td><input type="text" name="Competenz eExtra-3" size="10" value="67.09" readonly style="backgrou nd-color: #C0C0C0" onKeyUp="calcol a(this.form, 3)"></td>
                <td><input type="text" name="TotaleCom petenzeExtra-3" size="10" value="0" readonly style="backgrou nd-color: #C0C0C0"></td>

                <td><input type="text" name="ImportoBa seTrattenute-3" size="5" value="0" onKeyUp="calcol a(this.form, 3)"></td>
                <td><input type="text" name="NumeroOre Trattenute-3" size="10" value="0" onKeyUp="calcol a(this.form, 3)"></td>
                <td><input type="text" name="Trattenut eExtra-3" size="10" value="0" readonly style="backgrou nd-color: #C0C0C0" onKeyUp="calcol a(this.form, 3)"></td>
                <td><input type="text" name="TotaleTra ttenuteExtra-3" size="10" value="0" readonly style="backgrou nd-color: #C0C0C0"></td>
                </tr>
                <tr>
                <td><input type="text" name="ImportoBa se-2" size="5" value="55.4797" onKeyUp="calcol a(this.form, 2)"></td>
                <td><input type="text" name="NumeroOre-2" size="10" value="2" onKeyUp="calcol a(this.form, 2)"></td>
                <td><input type="text" name="Competenz eExtra-2" size="10" value="110.96" readonly style="backgrou nd-color: #C0C0C0" onKeyUp="calcol a(this.form, 2)"></td>
                <td><input type="text" name="TotaleCom petenzeExtra-2" size="10" value="0" readonly style="backgrou nd-color: #C0C0C0"></td>

                <td><input type="text" name="ImportoBa seTrattenute-2" size="5" value="0" onKeyUp="calcol a(this.form, 2)"></td>
                <td><input type="text" name="NumeroOre Trattenute-2" size="10" value="0" onKeyUp="calcol a(this.form, 2)"></td>
                <td><input type="text" name="Trattenut eExtra-2" size="10" value="0" readonly style="backgrou nd-color: #C0C0C0" onKeyUp="calcol a(this.form, 2)"></td>
                <td><input type="text" name="TotaleTra ttenuteExtra-2" size="10" value="0" readonly style="backgrou nd-color: #C0C0C0"></td>
                </tr>
                </table>
                </div>
                </form>
                </body>
                </html>

                [/html]

                Comment

                • Ferris
                  New Member
                  • Oct 2007
                  • 101

                  #23
                  Originally posted by viki1967
                  Sintax error
                  is yours an asp page? you should name your page as *.asp, not *.htm , and run it on IIS.

                  I test it,there's nothing wrong with the syntax.

                  Code:
                  	  <script language="javascript" type="text/javascript">
                  	  <!--
                  	  var outID = <%=1%>;
                  	  -->
                  	  </script>
                  then the outID will be valued 1,and the result will be shown in TotaleCompetenz eExtra-1

                  the javascript code is correct. I think you need to debug your asp code.

                  Comment

                  • viki1967
                    Contributor
                    • Oct 2007
                    • 263

                    #24
                    No...

                    Error in asp page:

                    [html]
                    <script language="javas cript" type="text/javascript">
                    <!--

                    var outID = ;

                    //-->
                    </script>
                    [/html]

                    var outID=<%=MySQL_ ID%>; its no defined....

                    Comment

                    • Ferris
                      New Member
                      • Oct 2007
                      • 101

                      #25
                      Would you please upload your asp page as an attachment.

                      Comment

                      • viki1967
                        Contributor
                        • Oct 2007
                        • 263

                        #26
                        Originally posted by Ferris
                        Would you please upload your asp page as an attachment.
                        Thanks... As?
                        it is not possible with upload... :(

                        Comment

                        • viki1967
                          Contributor
                          • Oct 2007
                          • 263

                          #27
                          My code attachment, help me please...
                          Attached Files

                          Comment

                          • Ferris
                            New Member
                            • Oct 2007
                            • 101

                            #28
                            maybe your error is Rs in line 12 is not defined. I move the js code. try it please:
                            Attached Files

                            Comment

                            • viki1967
                              Contributor
                              • Oct 2007
                              • 263

                              #29
                              Many thanks, but "TotaleCompeten zeExtra-" + outID is always 0...

                              Comment

                              • Ferris
                                New Member
                                • Oct 2007
                                • 101

                                #30
                                Originally posted by viki1967
                                Many thanks, but "TotaleCompeten zeExtra-" + outID is always 0...
                                oh...
                                what about "TrattenuteExtr a-" + outID?

                                and could you give me a link ?

                                Comment

                                Working...