www.webdeveloper.com
Results 1 to 2 of 2

Thread: it BUG about array but dont understand it PLEASEEE HELPP!!

  1. #1
    Join Date
    Jan 2003
    Location
    Thailand
    Posts
    2

    it BUG about array but dont understand it PLEASEEE HELPP!!

    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include file="config.inc.asp" -->
    <%
    set reg = Server.CreateObject("ADODB.Recordset")
    reg.ActiveConnection = ConnString
    reg.Source = "SELECT * FROM Country"
    reg.CursorType = 0
    reg.CursorLocation = 2
    reg.LockType = 3
    reg.Open()
    reg_numRows = 0
    %>
    <html>
    <head>
    <title>Database-driven Dynamic Drop-down Menu</title>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=">
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    var NoArray = new Array("('Select City','',true,true)");
    <%
    While (NOT reg.EOF)
    %>
    var <% response.write(reg.Fields.Item("CountryName").Value) &"Array"%> = new Array("('Select City','',true,true)",
    <%
    TempRegCode = (reg.Fields.Item("CountryName").Value)
    set ctry = Server.CreateObject("ADODB.Recordset")
    ctry.ActiveConnection = ConnString
    ctry.Source = "SELECT * FROM City WHERE CountryName='" &TempRegCode &"' Order By CityName"
    ctry.CursorType = 0
    ctry.CursorLocation = 2
    ctry.LockType = 3
    ctry.Open()
    ctry_numRows = 0

    While (NOT ctry.EOF)
    response.write ("""('") &(ctry.Fields.Item("CityName").Value) &"','" &(ctry.Fields.Item("CityName").Value) &"')"%>"<%
    ctry.MoveNext()
    If NOT ctry.EOF then
    response.write ","
    Else
    response.write ");"
    End If%>
    <%
    ' ctry.MoveNext()
    Wend
    If (ctry.CursorType > 0) Then
    ctry.MoveFirst
    Else
    ctry.Requery
    End If
    %>
    <%
    reg.MoveNext()
    Wend
    If (reg.CursorType > 0) Then
    reg.MoveFirst
    Else
    reg.Requery
    End If
    %>

    function populateCity(inForm,selected) {
    var selectedArray = eval(selected + "Array");
    while (selectedArray.length < inForm.City.options.length) {
    inForm.City.options[(inForm.City.options.length - 1)] = null;
    }
    for (var i=0; i < selectedArray.length; i++) {
    eval("inForm.City.options[i]=" + "new Option" + selectedArray[i]);
    }
    if (inForm.Country.options[0].value == '') {
    inForm.Country.options[0]= null;
    if ( navigator.appName == 'Netscape') {
    if (parseInt(navigator.appVersion) < 4) {
    window.history.go(0);
    }
    else {
    if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
    window.history.go(0);
    }
    }
    }
    }
    }
    // End -->
    </script>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <form name="globe" action="Default.asp" method="post">
    <select name="Country" onChange="populateCity(document.globe,document.globe.Country.options[document.globe.Country.selectedIndex].value)">
    <option value="No" selected>Select Country</option>
    <%
    While (NOT reg.EOF)
    %>
    <option value="<%=(reg.Fields.Item("CountryName").Value)%>"><%=(reg.Fields.Item("CountryName").Value)%></option>
    <%
    reg.MoveNext()
    Wend
    If (reg.CursorType > 0) Then
    reg.MoveFirst
    Else
    reg.Requery
    End If
    %>
    </select>
    <select name="City">
    <option value=''>Select City</option>
    </select>
    </form>
    </body>
    </html>
    <%
    ctry.Close()
    %>
    <%
    reg.Close()
    %>

  2. #2
    Join Date
    Jan 2003
    Location
    Thailand
    Posts
    2
    line above it not bug but when i change feild to compare to countryID (now countryName) it bug countryID in database is autonumber whow know what wrong ? i dont understand it !

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles