Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. javascripts help

javascripts help

Scheduled Pinned Locked Moved Web Development
helpdata-structures
10 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    henli
    wrote on last edited by
    #1

    I need to create more than one text box with the same name(this call array),with the code; for i = 1 to CInt(request.Form("quantity")) count = count + 1 serial_field = "serial"&count end loop then, when I need to check whether user already fill in this text box, I can not access that text box name.Text box name suppose to be serial1, serial2 and so on.I am using this code; for (a=o;a<=30;a++){ if (document.Reg.element.serial[a].value == "") { err = true; msgstring = "Fill in serial number"; } } I can access the value only if I directly use the name like; if (document.Reg.element.serial1.value == "") { err = true; msgstring = "Fill in serial number"; } Any suggestion what I should do to solve this problem. I am sorry my explanation is quite massy. Thanks

    R R 2 Replies Last reply
    0
    • H henli

      I need to create more than one text box with the same name(this call array),with the code; for i = 1 to CInt(request.Form("quantity")) count = count + 1 serial_field = "serial"&count end loop then, when I need to check whether user already fill in this text box, I can not access that text box name.Text box name suppose to be serial1, serial2 and so on.I am using this code; for (a=o;a<=30;a++){ if (document.Reg.element.serial[a].value == "") { err = true; msgstring = "Fill in serial number"; } } I can access the value only if I directly use the name like; if (document.Reg.element.serial1.value == "") { err = true; msgstring = "Fill in serial number"; } Any suggestion what I should do to solve this problem. I am sorry my explanation is quite massy. Thanks

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      serial_field = "serial"&count gives all the fields different names - serial1, serial2 etc... Just use serial_field = "serial";

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      A 1 Reply Last reply
      0
      • R Ryan Binns

        serial_field = "serial"&count gives all the fields different names - serial1, serial2 etc... Just use serial_field = "serial";

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Ya, that true according to logic but the problem bow, the object(text box) has been created first than we need to check when user click on save button. How we can refer to the object name?

        R 1 Reply Last reply
        0
        • A Anonymous

          Ya, that true according to logic but the problem bow, the object(text box) has been created first than we need to check when user click on save button. How we can refer to the object name?

          R Offline
          R Offline
          Ryan Binns
          wrote on last edited by
          #4

          I'm not a javascript expert, but you should be able to use

          document.all.serial[0].value
          document.all.serial[1].value
          etc...

          Hope this helps,

          Ryan

          "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

          H B 2 Replies Last reply
          0
          • R Ryan Binns

            I'm not a javascript expert, but you should be able to use

            document.all.serial[0].value
            document.all.serial[1].value
            etc...

            Hope this helps,

            Ryan

            "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

            H Offline
            H Offline
            henli
            wrote on last edited by
            #5

            Ya, it suppose can work but I don't know why it can't Anyway Thanks for your help.

            L 1 Reply Last reply
            0
            • H henli

              I need to create more than one text box with the same name(this call array),with the code; for i = 1 to CInt(request.Form("quantity")) count = count + 1 serial_field = "serial"&count end loop then, when I need to check whether user already fill in this text box, I can not access that text box name.Text box name suppose to be serial1, serial2 and so on.I am using this code; for (a=o;a<=30;a++){ if (document.Reg.element.serial[a].value == "") { err = true; msgstring = "Fill in serial number"; } } I can access the value only if I directly use the name like; if (document.Reg.element.serial1.value == "") { err = true; msgstring = "Fill in serial number"; } Any suggestion what I should do to solve this problem. I am sorry my explanation is quite massy. Thanks

              R Offline
              R Offline
              Rahul Walavalkar
              wrote on last edited by
              #6

              Try this: (Note: Change the 6 in the first "for loop" with your total number of textboxes.) function fnCheck() { var strTextBoxName; for(var i=1;i<6;i++) { strTextBoxName = "serial" + i; for(var j=0;j

              H 1 Reply Last reply
              0
              • R Ryan Binns

                I'm not a javascript expert, but you should be able to use

                document.all.serial[0].value
                document.all.serial[1].value
                etc...

                Hope this helps,

                Ryan

                "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                B Offline
                B Offline
                Bjoern Graf
                wrote on last edited by
                #7

                This would work if the fields all have the same name (serial in this example). But here the fields include an increasing number so he needs to use: for(var i = x; i < y; i++) { document.formName["serial" + i]; } where x is the number of the first field and y is the number of the last.

                R 1 Reply Last reply
                0
                • B Bjoern Graf

                  This would work if the fields all have the same name (serial in this example). But here the fields include an increasing number so he needs to use: for(var i = x; i < y; i++) { document.formName["serial" + i]; } where x is the number of the first field and y is the number of the last.

                  R Offline
                  R Offline
                  Ryan Binns
                  wrote on last edited by
                  #8

                  Yeah I know, hence my first reply :)

                  Ryan

                  "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                  1 Reply Last reply
                  0
                  • R Rahul Walavalkar

                    Try this: (Note: Change the 6 in the first "for loop" with your total number of textboxes.) function fnCheck() { var strTextBoxName; for(var i=1;i<6;i++) { strTextBoxName = "serial" + i; for(var j=0;j

                    H Offline
                    H Offline
                    henli
                    wrote on last edited by
                    #9

                    Ya, that great, I get all the idea and it work. Thanks guys.

                    1 Reply Last reply
                    0
                    • H henli

                      Ya, it suppose can work but I don't know why it can't Anyway Thanks for your help.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      What about after creating serial1, serial2, etc, using function foo(bar) { eval('serial'+bar+'.value = ...'); } HTH Paul ;)

                      Tiny problem with said member has been corrected.
                      Chris Maunder

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups