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. ASP.NET
  4. how to access counter in for loop

how to access counter in for loop

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripthtmlsysadmindebugging
3 Posts 3 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.
  • M Offline
    M Offline
    mhd sbt
    wrote on last edited by
    #1

    hi to all how can i acceess 'i' in for loop thanks in advance

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form runat="server">

            <script type="text/javascript">
                function addAspPopUp() {
                    debugger
                    var optionText = document.getElementById('aspNewOption').value;
                    var textBox = document.getElementById('aspNewOption');
                    var objSelect = document.getElementById('aspMySelect');
                    
                    listCount=<%=objListItems.Count%>;
                    for (var i=0;i<=listCount;i++)
                    {
                        objSelect\[objSelect.length\] = new Option('<%=objListItems\[i\]%>');
                       
                        textBox.value = "";
                    }
                }
            </script>
            <input type="button" id="btnRegister" onclick="ConvertDate()" value="test" />
            <input type="button" id="Button2" onclick="addAspPopUp()" value="test2" />
        
    
        
    </form>
    

    </body>
    </html>

    Z V 2 Replies Last reply
    0
    • M mhd sbt

      hi to all how can i acceess 'i' in for loop thanks in advance

      <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>

      <html xmlns="http://www.w3.org/1999/xhtml">
      <head runat="server">
      <title></title>
      </head>
      <body>
      <form runat="server">

              <script type="text/javascript">
                  function addAspPopUp() {
                      debugger
                      var optionText = document.getElementById('aspNewOption').value;
                      var textBox = document.getElementById('aspNewOption');
                      var objSelect = document.getElementById('aspMySelect');
                      
                      listCount=<%=objListItems.Count%>;
                      for (var i=0;i<=listCount;i++)
                      {
                          objSelect\[objSelect.length\] = new Option('<%=objListItems\[i\]%>');
                         
                          textBox.value = "";
                      }
                  }
              </script>
              <input type="button" id="btnRegister" onclick="ConvertDate()" value="test" />
              <input type="button" id="Button2" onclick="addAspPopUp()" value="test2" />
          
      
          
      </form>
      

      </body>
      </html>

      Z Offline
      Z Offline
      ZurdoDev
      wrote on last edited by
      #2

      What do you mean how to access i? Just use it. And why post so much other code that is not relevant?

      There are only 10 types of people in the world, those who understand binary and those who don't.

      1 Reply Last reply
      0
      • M mhd sbt

        hi to all how can i acceess 'i' in for loop thanks in advance

        <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>

        <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
        <title></title>
        </head>
        <body>
        <form runat="server">

                <script type="text/javascript">
                    function addAspPopUp() {
                        debugger
                        var optionText = document.getElementById('aspNewOption').value;
                        var textBox = document.getElementById('aspNewOption');
                        var objSelect = document.getElementById('aspMySelect');
                        
                        listCount=<%=objListItems.Count%>;
                        for (var i=0;i<=listCount;i++)
                        {
                            objSelect\[objSelect.length\] = new Option('<%=objListItems\[i\]%>');
                           
                            textBox.value = "";
                        }
                    }
                </script>
                <input type="button" id="btnRegister" onclick="ConvertDate()" value="test" />
                <input type="button" id="Button2" onclick="addAspPopUp()" value="test2" />
            
        
            
        </form>
        

        </body>
        </html>

        V Offline
        V Offline
        vinay_sinha
        wrote on last edited by
        #3

        there is no point of asking, 'i' is there u can use, do you mean other than this?

        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