Loading ...
Sorry, an error occurred while loading the content.

Re: [JavaScript] help me

Expand Messages
  • f3l
    ... to access the selectbox s value, use $( sel_id ).value If I select 2 on that select box, it appear 2 textbox s below the select box ... to access the
    Message 1 of 10 , Jul 5, 2006
    • 0 Attachment
      On 7/5/06, Haris Agustin <hagustin@...> wrote:
      >
      > Hi Everyone,
      >
      > My Name is Haris
      >
      > I Have select box which contains or values 1,2,3 etc
      >
      > If I select 1 on that select box, it appear 1 text box below the select
      > box
      > that I mention before
      >

      to access the selectbox's value, use $("sel_id").value

      If I select 2 on that select box, it appear 2 textbox's below the select box
      >

      to access the user's click , use onchange

      If I select 20 on that select box, it appear 20 textbox's below the select
      > box
      >

      once you have the number, use a loop control structure (while,for,etc) to
      append to a page element, the html required (the checkbox)

      to append stuff to a web page, you can use innerHTML, altough DOM methods
      are recomended (fomr some reason).

      just stay away from document.write.


      and so on.
      >
      > I don't know the javascript to make that possible
      >
      > Please help me for my problem above.
      >
      > Thanks
      >
      >
      >

      --
      //f3l
      there seems to be quite a debate, on wether linux is a toaster, or a unix
      clone...


      [Non-text portions of this message have been removed]
    • Dave
      could you please post the HTML/javascript that you have to be more clear? Haris Agustin wrote: Hi Everyone, My Name is Haris I
      Message 2 of 10 , Jul 5, 2006
      • 0 Attachment
        could you please post the HTML/javascript that you have to be more clear?

        Haris Agustin <hagustin@...> wrote: Hi Everyone,

        My Name is Haris

        I Have select box which contains or values 1,2,3 etc

        If I select 1 on that select box, it appear 1 text box below the select box
        that I mention before

        If I select 2 on that select box, it appear 2 textbox's below the select box

        If I select 20 on that select box, it appear 20 textbox's below the select
        box

        and so on.

        I don't know the javascript to make that possible

        Please help me for my problem above.

        Thanks

        [Non-text portions of this message have been removed]






        [Non-text portions of this message have been removed]
      • gmmmg1
        what is the wrong in this program pleas replay test
        Message 3 of 10 , Aug 18, 2007
        • 0 Attachment
          what is the wrong in this program
          pleas replay





          <html xmlns = "http://www.w3.org/1999/xhtml">
          <head> <title> test </title>
          <script type = "text/javascript">
          onerror=handleErr
          function handleErr(msg,url,l)
          {
          txt="There was an error on this page.\n\n"
          txt+="Error: " + msg + "\n"
          txt+="URL: " + url + "\n"
          txt+="Line: " + l + "\n\n"
          txt+="Click OK to continue.\n\n"
          alert(txt)
          return true
          }

          // name,age,dayes,time,rate,salary
          name = prompt("name of employee # 1", "")
          age = prompt("Age", "")
          dayes = prompt("# of dayes worked", "")
          time = prompt("part time(0),full time(1)", "")
          rate = prompt("rate per hour", "")
          question = confirm("enter more employee?")








          function salary()
          {
          if(age<30)
          {
          if(time==0)
          {return dayes*4*4*rate}
          else if(time==0)
          {return dayes*8*4*rate}
          }

          else if(age>30&&age<40)
          {
          if(time==0)
          {return dayes*4*4*rate*1.1}
          else if(time==0)
          {return dayes*8*4*rate*1.1}
          }

          else if(age>40&&age<50)
          {
          if(time==0)
          {return dayes*4*4*rate*1.2}
          else if(time==0)
          {return dayes*8*4*rate*1.2}
          }

          else if(age>50)
          {
          if(time==0)
          {return dayes*4*4*rate*1.3}
          else if(time==0)
          {return dayes*8*4*rate*1.3}
          }

          }


          function tax(salary)
          {
          if(salary>1000)
          {
          return tax=salary*.05
          }

          else if(salary>2000)
          {
          return tax=salary*.1
          }

          else if(salary>4000)
          {
          return tax=salary*.15
          }
          else
          tax=0
          net_salary=salary-tax
          }


          </script>
          </head>
          <body>
          <script type="text/javascript">


          <table border = "border">

          <tr>
          <th> emp name</th>
          <th> age </th>
          <th> salary </th>
          <th> tax </th>
          <th> net salary </th>
          </tr>

          <tr>
          <td> document.write(name) </td>
          <td > document.write(age) </td>
          <td > document.write(salary) </td>
          <td > document.write(tax) </td>
          <td > document.write(net_salary) </td>
          </tr>
          </table>
          </script>
          </body>
          </html>
        • David Smart
          Well, you haven t declared your variables, and you haven t put semicolons at the end of your statements. You don t indent your code, and you don t seem to
          Message 4 of 10 , Aug 20, 2007
          • 0 Attachment
            Well, you haven't declared your variables, and you haven't put semicolons at
            the end of your statements. You don't indent your code, and you don't seem
            to have a consistent style.

            Those are the very visible things that are wrong with your code.

            But that mightn't be what you had in mind. If not, what is your code
            supposed to do, and what is it doing? And what testing have YOU done on it?

            I notice that you have

            if(time==0)
            {return dayes*4*4*rate}
            else if(time==0)
            {return dayes*8*4*rate}

            and similar in several places, which is never going to do the "else if"
            part.

            You also have

            return tax=salary*.05

            and similar, which is certainly not going to do what you want. Do you want
            an assignment statement or a return - you can't have both.

            And your tax routine has

            net_salary=salary-tax

            which is possibly wrong, or perhaps just a side-effect that you most
            certainly shouldn't have.

            You also seem to have a function called "salary" and a global variable
            called "salary". I'm not sure of this, though, because the only place that
            salary appears as a variable is in the document.write statement. The same
            seems to be true of "tax".

            Lastly, you never seem to call the function "salary" or the function "tax"
            from anywhere.

            There are possibly other things too, but that's where I stopped looking. I
            assume that this is a programming exercise as part of your homework. You
            need to (1) talk to your instructors about getting more instruction, and (2)
            begin with a much more simple example (perhaps just request a single value
            and display it).

            Regards, Dave S

            PS the word "days" doesn't have an "e" in it.

            PPS "Help me" is a bad subject for an e-mail. Make your subject much more
            informative please.

            ----- Original Message -----
            From: "gmmmg1" <gmmmg1@...>
            To: <JavaScript_Official@yahoogroups.com>
            Sent: Sunday, August 19, 2007 3:07 AM
            Subject: [JavaScript] help me


            > what is the wrong in this program
            > pleas replay
            >
            >
            >
            >
            >
            > <html xmlns = "http://www.w3.org/1999/xhtml">
            > <head> <title> test </title>
            > <script type = "text/javascript">
            > onerror=handleErr
            > function handleErr(msg,url,l)
            > {
            > txt="There was an error on this page.\n\n"
            > txt+="Error: " + msg + "\n"
            > txt+="URL: " + url + "\n"
            > txt+="Line: " + l + "\n\n"
            > txt+="Click OK to continue.\n\n"
            > alert(txt)
            > return true
            > }
            >
            > // name,age,dayes,time,rate,salary
            > name = prompt("name of employee # 1", "")
            > age = prompt("Age", "")
            > dayes = prompt("# of dayes worked", "")
            > time = prompt("part time(0),full time(1)", "")
            > rate = prompt("rate per hour", "")
            > question = confirm("enter more employee?")
            >
            >
            >
            >
            >
            >
            >
            >
            > function salary()
            > {
            > if(age<30)
            > {
            > if(time==0)
            > {return dayes*4*4*rate}
            > else if(time==0)
            > {return dayes*8*4*rate}
            > }
            >
            > else if(age>30&&age<40)
            > {
            > if(time==0)
            > {return dayes*4*4*rate*1.1}
            > else if(time==0)
            > {return dayes*8*4*rate*1.1}
            > }
            >
            > else if(age>40&&age<50)
            > {
            > if(time==0)
            > {return dayes*4*4*rate*1.2}
            > else if(time==0)
            > {return dayes*8*4*rate*1.2}
            > }
            >
            > else if(age>50)
            > {
            > if(time==0)
            > {return dayes*4*4*rate*1.3}
            > else if(time==0)
            > {return dayes*8*4*rate*1.3}
            > }
            >
            > }
            >
            >
            > function tax(salary)
            > {
            > if(salary>1000)
            > {
            > return tax=salary*.05
            > }
            >
            > else if(salary>2000)
            > {
            > return tax=salary*.1
            > }
            >
            > else if(salary>4000)
            > {
            > return tax=salary*.15
            > }
            > else
            > tax=0
            > net_salary=salary-tax
            > }
            >
            >
            > </script>
            > </head>
            > <body>
            > <script type="text/javascript">
            >
            >
            > <table border = "border">
            >
            > <tr>
            > <th> emp name</th>
            > <th> age </th>
            > <th> salary </th>
            > <th> tax </th>
            > <th> net salary </th>
            > </tr>
            >
            > <tr>
            > <td> document.write(name) </td>
            > <td > document.write(age) </td>
            > <td > document.write(salary) </td>
            > <td > document.write(tax) </td>
            > <td > document.write(net_salary) </td>
            > </tr>
            > </table>
            > </script>
            > </body>
            > </html>
            >
            >
            >
            >
            >
            >
            > Visit http://aiaiai.com for more groups to join
            > Yahoo! Groups Links
            >
            >
            >
          • soren.j.winslow@cummins.com
            What is the error you are getting and what line number? Soren gmmmg1 Sent by: JavaScript_Official@yahoogroups.com 08/18/2007 10:07 AM
            Message 5 of 10 , Aug 20, 2007
            • 0 Attachment
              What is the error you are getting and what line number?

              Soren





              "gmmmg1" <gmmmg1@...>
              Sent by: JavaScript_Official@yahoogroups.com
              08/18/2007 10:07 AM
              Please respond to
              JavaScript_Official@yahoogroups.com


              To
              JavaScript_Official@yahoogroups.com
              cc

              Subject
              [JavaScript] help me






              what is the wrong in this program
              pleas replay





              <html xmlns = "http://www.w3.org/1999/xhtml">
              <head> <title> test </title>
              <script type = "text/javascript">
              onerror=handleErr
              function handleErr(msg,url,l)
              {
              txt="There was an error on this page.\n\n"
              txt+="Error: " + msg + "\n"
              txt+="URL: " + url + "\n"
              txt+="Line: " + l + "\n\n"
              txt+="Click OK to continue.\n\n"
              alert(txt)
              return true
              }

              // name,age,dayes,time,rate,salary
              name = prompt("name of employee # 1", "")
              age = prompt("Age", "")
              dayes = prompt("# of dayes worked", "")
              time = prompt("part time(0),full time(1)", "")
              rate = prompt("rate per hour", "")
              question = confirm("enter more employee?")








              function salary()
              {
              if(age<30)
              {
              if(time==0)
              {return dayes*4*4*rate}
              else if(time==0)
              {return dayes*8*4*rate}
              }

              else if(age>30&&age<40)
              {
              if(time==0)
              {return dayes*4*4*rate*1.1}
              else if(time==0)
              {return dayes*8*4*rate*1.1}
              }

              else if(age>40&&age<50)
              {
              if(time==0)
              {return dayes*4*4*rate*1.2}
              else if(time==0)
              {return dayes*8*4*rate*1.2}
              }

              else if(age>50)
              {
              if(time==0)
              {return dayes*4*4*rate*1.3}
              else if(time==0)
              {return dayes*8*4*rate*1.3}
              }

              }


              function tax(salary)
              {
              if(salary>1000)
              {
              return tax=salary*.05
              }

              else if(salary>2000)
              {
              return tax=salary*.1
              }

              else if(salary>4000)
              {
              return tax=salary*.15
              }
              else
              tax=0
              net_salary=salary-tax
              }


              </script>
              </head>
              <body>
              <script type="text/javascript">


              <table border = "border">

              <tr>
              <th> emp name</th>
              <th> age </th>
              <th> salary </th>
              <th> tax </th>
              <th> net salary </th>
              </tr>

              <tr>
              <td> document.write(name) </td>
              <td > document.write(age) </td>
              <td > document.write(salary) </td>
              <td > document.write(tax) </td>
              <td > document.write(net_salary) </td>
              </tr>
              </table>
              </script>
              </body>
              </html>






              Visit http://aiaiai.com for more groups to join
              Yahoo! Groups Links






              [Non-text portions of this message have been removed]
            • Jon Stephens
              ... You can t do this. A element cannot contain other HTML tags. -- This message has not been scanned for viruses. Since I do not use a Microsoft
              Message 6 of 10 , Aug 22, 2007
              • 0 Attachment
                > <script type="text/javascript">
                >
                >
                > <table border = "border">
                >
                > <tr>
                > <th> emp name</th>
                > <th> age </th>
                > <th> salary </th>
                > <th> tax </th>
                > <th> net salary </th>
                > </tr>
                >
                > <tr>
                > <td> document.write(name) </td>
                > <td > document.write(age) </td>
                > <td > document.write(salary) </td>
                > <td > document.write(tax) </td>
                > <td > document.write(net_salary) </td>
                > </tr>
                > </table>
                > </script>

                You can't do this. A <script> element cannot contain other HTML tags.


                --
                This message has not been scanned for viruses.

                Since I do not use a Microsoft operating
                system or software, and use only plaintext
                for email, there is little need for me to do so.
              • Eng. Ahmed Youssef
                You should do : document.write( ) document.write(name); document.write( ) ... You can t do this. A element cannot contain other HTML tags.
                Message 7 of 10 , Aug 23, 2007
                • 0 Attachment
                  You should do :

                  document.write("<td>")

                  document.write(name);

                  document.write("</td>")





                  > <script type="text/javascript">
                  >
                  >
                  > <table border = "border">
                  >
                  > <tr>
                  > <th> emp name</th>
                  > <th> age </th>
                  > <th> salary </th>
                  > <th> tax </th>
                  > <th> net salary </th>
                  > </tr>
                  >
                  > <tr>
                  > <td> document.write(name) </td>
                  > <td > document.write(age) </td>
                  > <td > document.write(salary) </td>
                  > <td > document.write(tax) </td>
                  > <td > document.write(net_salary) </td>
                  > </tr>
                  > </table>
                  > </script>

                  You can't do this. A <script> element cannot contain other HTML tags.

                  --
                  This message has not been scanned for viruses.

                  Since I do not use a Microsoft operating
                  system or software, and use only plaintext
                  for email, there is little need for me to do so.





                  [Non-text portions of this message have been removed]
                • Akhilesh Tiwari
                  i want to make the form of registration .what is the code of country,state ,city who come automatically as in yahoo or gmail registration [Non-text portions of
                  Message 8 of 10 , Aug 1, 2008
                  • 0 Attachment
                    i want to make the form of registration .what is the code of country,state
                    ,city who come automatically as in yahoo or gmail registration


                    [Non-text portions of this message have been removed]
                  Your message has been successfully submitted and would be delivered to recipients shortly.