|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Incremental Variable
I have this in javascript which is working:
Code:
var i=0;
for (i=1;i<=25;i++)
{
if (document.frmUser.elements["CHANGED"+i].value=="T")
{
alert('error3');
if (document.frmUser.elements["Manage_Area_Name"+i].value == "XXX")
{
alert('error1');
}
else
{
alert('error2');
}
}
}
But I need it to be in VBScript. What would I need to change? |
|
#2
|
|||
|
|||
|
I'm just wondering how I would step through the loop of checking the variables when I have them named CHANGED1, CHANGED2, CHANGED3, and there could be any given amount of them.
|
|
#3
|
||||
|
||||
|
-->Thread moved to ASP Forum
__________________
Come JOIN the party!!! Quote of the Month: Trouble: Luck can't last a lifetime unless you die young. Questions to Ponder: Do cemetery workers prefer the graveyard shift? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright© 2008 sbenj69 |
|
#4
|
||||
|
||||
|
you mean client side VBScript or server side VBScript, which is actually ASP?
if client side, are you aware that it's IE only? |
|
#5
|
|||
|
|||
|
I'm aware, it's an internal application and Internet Explorer 6 is the standard browser for the company right now. And nobody has administrative rights on their machines.
|
|
#6
|
||||
|
||||
|
Quote:
post full error message you get and we'll help you solve this. |
|
#7
|
|||
|
|||
|
Thank you guys. I really only have 1 issue left so I'm getting through it with your help. I have a form on page 1 that gets submitted to page 2. Page 2 checks all the values in the form against the database and writes the value out to an array if it's already in the database. Then it creates a session value for the array and passes it back to page 1 which then pops up an alert containing each value from the session array.
My problem comes when I try to dynamically set the array size. On the server side I try to use "redim PRESERVE errorArray(errorCount)" but I don't think I can run that server side. It doesn't work for me. And then when the array is passed back to the client side, I try to set my local array value to the size of it by using ubound(errorArray) after assigning the local value to the session value but that doesn't work either, it breaks the page. There's one last issue but I'll let you work with these first. My client side code: Code:
<!--#include file="../strConnect.asp"#-->
<% Session.CodePage = 65001 ' UTF-8 code %>
<%
' Dim Variables
Dim fieldnames
Dim fld, fldCount, ColorOn, Sortkey
Dim Con, rs_Users, x, strkey, mySQL
Set Con = Server.CreateObject( "ADODB.Connection" )
' Pick up any Passed Variables
if Request.QueryString("table") <> "" then
Session("mytable") = Request.QueryString("table")
end if
if Request.QueryString("sort") <> "" then
sortkey = Request.QueryString("sort")
end if
%>
<HTML>
<HEAD>
<title>Location Management - Master Table Info</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<STYLE TYPE="text/css">
TD.large { font-size: 10pt; text-transform: uppercase;}
TD.small { font-size: 8pt;}
tr.blue {background-color: lightblue}
tr.white {background-color: white}
tr.titles {font-family: 'Verdana'; font-style: bold; font-weight: bold; background-color: lightblue}
input.Inputblue { font-size: 8pt; border: 1; background-color: lightblue}
input.Inputwhite { font-size: 8pt; border: 1; background-color: white}
input.borderon { font-size: 8pt; border: 1; background-color: lightblue}
</STYLE>
</HEAD>
<BODY topmargin="0" leftmargin="0" text="#4F2403" link="#4F2403" vlink="#4F2403" alink="#4F2403" rightMargin=0 bottomMargin=0>
<!--#include file="../top.asp"-->
<H1><% = Session("mytable") %> Information </H1>
<form method="post" Name=frmUser action="masupdate.asp">
<TABLE Border=0 RULES="Rows" CELLSPACING=0 CELLPADDING=2>
<TR Class=titles>
<%
Dim errorArray, errorCount, errorString
redim errorArray(10)
errorCount = Session("errorCount")
errorArray = Session("errorArray")
If errorCount > 0 Then
For x = 0 to errorCount - 1
errorString = errorString & "\r- " & errorArray(x)
Next
Response.write("<script type=""text/javascript"">alert(""The following values are invalid and were not committed: \r" & errorString & "\r\r> Each Manager can only be associated with a single area/region.\r> Each associated ID must be a valid Regional Manager ID.""); </script>")
End If
session("searchuser")=""
ColorOn = False
Con.Open strConnect
Select Case ucase(Session("myTable"))
Case "REGION_LIST"
mySQL = "SELECT * FROM " & Session("myTable") & " WHERE Region_ID NOT LIKE 'JR%';"
Case "DISTRICT_LIST"
mySQL = "SELECT * FROM " & Session("myTable") & ";"
Case "AREA_LIST"
mySQL = "SELECT * FROM " & Session("myTable") & ";"
Case Else
mySQL = "SELECT * FROM " & Session("myTable") & ";"
End Select
Set rs_Users = Con.Execute( mySQL )
If Not Rs_Users.EOF then
fldCount = rs_Users.Fields.Count
ReDim fieldnames(fldcount)
For x = 0 to fldCount - 1
Set fld = rs_Users.Fields.item(x)
fieldnames(x) = fld.Name
If x < 1 then
strkey = fld.Name
If sortkey = "" then
sortkey=strkey
End If
End if
HeaderLine = "<TD Class=Large>" & fld.Name & " <A TITLE=" & Chr(34) & "Sort By " & fld.Name & Chr(34) &_
" HREF=maslist.asp?table=" & Session("mytable") & "&Sort=" & fld.Name & ">"
If sortkey = fld.Name then
HeaderLine = HeaderLine & "<IMG BORDER=0 SRC=Desc.gif></A> </TD>"
Else
HeaderLine = HeaderLine & "<IMG BORDER=0 SRC=Sort.gif></A> </TD>"
End If
Response.Write HeaderLine
Next
End if
x = 0
rs_Users.Close
Select Case ucase(Session("myTable"))
Case "REGION_LIST"
mySQL = "SELECT * FROM " & Session("myTable") & " WHERE Region_ID NOT LIKE 'J%'" & " ORDER BY " & sortkey & ";"
Case "DISTRICT_LIST"
mySQL = "SELECT * FROM " & Session("myTable") & " WHERE District_ID NOT LIKE 'J%'" & " ORDER BY " & sortkey & ";"
Case "AREA_LIST"
mySQL = "SELECT * FROM " & Session("myTable") & " WHERE Area_ID NOT LIKE 'J%'" & " ORDER BY " & sortkey & ";"
Case Else
mySQL = "SELECT * FROM " & Session("myTable") & " ORDER BY " & sortkey & ";"
End Select
Set rs_Users = Con.Execute( mySQL )
Count = 0
%>
<TD><Input CLASS=borderon TYPE=TEXT SIZE=1 MAXLENGTH=1></INPUT></TD>
</TR>
<%
If not rs_Users.EOF then
rs_Users.movefirst
Do While NOT rs_Users.EOF
Count = Count + 1
If ColorOn = False then
Response.Write "<TR Class=white>"
For x = 0 to fldCount - 1
Response.Write "<TD Class=small><INPUT NAME=" & CHR(34) & fieldnames(x) & Count & CHR(34) & " ONCHANGE=vbscript:Document.frmUser.CHANGED" & Count & ".Value=" & CHR(34) & "T" & CHR(34) & " TYPE=TEXT CLASS=INPUTWHITE VALUE=" & CHR(34) & trim(rs_Users.Fields.item(x)) & CHR(34) & "></INPUT></TD>" & vbCRLF
Next
Response.Write "<TD><Input NAME=CHANGED" & Count & " CLASS=INPUTWHITE TYPE=HIDDEN SIZE=1 MAXLENGTH=1></INPUT></TD>" & vbCRLF & vbCRLF
ColorOn = True
Else
Response.Write "<TR Class=blue>"
For x = 0 to fldCount - 1
Response.Write "<TD Class=small><INPUT NAME=" & CHR(34) & fieldnames(x) & Count & CHR(34) & " ONCHANGE=vbscript:Document.frmUser.CHANGED" & Count & ".Value=" & CHR(34) & "T" & CHR(34) & " TYPE=TEXT CLASS=INPUTBLUE VALUE=" & CHR(34) & trim(rs_Users.Fields.item(x)) & CHR(34) & "></INPUT></TD>" & vbCRLF
Next
Response.Write "<TD><Input NAME=CHANGED" & Count & " CLASS=INPUTBLUE TYPE=HIDDEN SIZE=1 MAXLENGTH=1></INPUT></TD>" & vbCRLF & vbCRLF
ColorOn = False
End If
Response.Write "</TR>"
rs_Users.Movenext
Loop
End if
%>
</TABLE>
<% Response.Write "<INPUT type=""hidden"" name=""RowCount"" Value=""" & Count & """><INPUT type=""hidden"" name=""TableName"" Value=""" & Session("mytable") & """><BR>" %>
<BR>
<input type="hidden" width=50 name="table" value="<% =Session("mytable") %>"><BR>
<input type="button" value="<- Back" onClick="SureMain('master.asp')" id=button1 name=button1>
<input type="submit" value="Update" id=submit1 name=submit1>
<input type="button" value="Add New" onClick="SureMain('masnew.asp?Table=<%=Session("myTable")%>')" id=button1 name=button1>
</Form>
<%
Session("mytable") = ""
strkey = ""
rs_Users.close
Con.Close
Set rs_Users = nothing
%>
<!--#include file="../bottom.asp"-->
<script language="vbscript">
Function SureMain(strloc)
document.location = strloc
End Function
</script>
And my server side code: Code:
<!--#include file="../strConnect.asp"#-->
<%
Dim Con, mySQL, rs_Users, rsupdate, sqlupdate, fldCount, myfield, savewhere, updatetype, mySQL2, rs_users2, rs_users3, mySQL3, mySQL4, mySQL5, rs_Users4, rs_Users5, mySQL6, rs_Users6, mySQL7, rs_Users7, mySQL8, rs_Users8, mySQL11, rs_Users11, mySQL12, rs_Users12
Dim RowCount
Dim errorArray(10), errorCount
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open strConnect
updatetype = trim(request("type"))
tablename = Trim(Request.Form("Tablename"))
RowCount = Trim(Request.Form("RowCount"))
Response.Write RowCount & TableName
errorCount = 0
For x = 1 to RowCount
If Trim(Request.Form("CHANGED" & x) = "T") Then
if TableName = "CJI_AreaMgrs" Then
mySQL6 = "SELECT * FROM CJI_RegionMgrs WHERE Regional_Mgr_ID = '" & Trim(Request.Form("Regional_Mgr_ID" & x)) & "';"
response.write mysql6
Set rs_Users6 = Con.Execute( mySQL6 )
mySQL2 = "SELECT * FROM CJI_AreaMgrs WHERE Area_Mgr = '" & Trim(Request.Form("Area_Mgr" & x)) & "';"
response.write mysql2
Set rs_Users2 = Con.Execute( mySQL2 )
mySQL3 = "SELECT * FROM CJI_AreaMgrs WHERE Manage_Area_Name = '" & Trim(Request.Form("Manage_Area_Name" & x)) & "';"
response.write mysql3
Set rs_Users3 = Con.Execute( mySQL3 )
mySQL11 = "SELECT * FROM CJI_AreaMgrs WHERE Area_MgrJP = '" & Trim(Request.Form("Area_MgrJP" & x)) & "';"
response.write mysql11
Set rs_Users11 = Con.Execute( mySQL11 )
mySQL12 = "SELECT * FROM CJI_RegionMgrs WHERE Regional_Mgr_Name_JP = '" & Trim(Request.Form("Regoinal_Mgr_Name_JP" & x)) & "';"
Response.Write mySQL12
Set rs_Users12 = Con.Execute( mySQL12 )
if NOT rs_Users12.EOF AND Trim(Request.Form("Regional_Mgr_Name_JP" & x)) <> "" Then
errorArray(errorCount) = Trim(Request.Form("Regional_Mgr_Name_JP" & x))
errorCount = errorCount + 1
else
Response.Write x & " = has been changed. <br><br>"
Call updateRegionalManagerJapanese()
End If
if NOT rs_Users11.EOF AND Trim(Request.Form("Area_MgrJP" & x)) <> "" Then
errorArray(errorCount) = Trim(Request.Form("Area_MgrJP" & x))
errorCount = errorCount + 1
else
Response.Write x & " = has been changed. <br><br>"
Call updateAreaManagerJapanese()
End If
If rs_Users6.EOF AND Trim(Request.Form("Regional_Mgr_ID" & x)) <> "" Then
errorArray(errorCount) = Trim(Request.Form("Regional_Mgr_ID" & x))
errorCount = errorCount + 1
else
Response.Write x & " - Has been changed <BR><BR>"
Call updateID()
End If
If Not rs_Users2.EOF Then
mySQL7 = "SELECT Area_ID FROM CJI_AreaMgrs WHERE Area_Mgr = '" & Trim(Request.Form("Area_Mgr" & x)) & "' AND Area_ID != '" & Trim(Request.Form("Area_ID" & x)) & "';"
Set rs_Users7 = Con.Execute( mySQL7 )
if NOT rs_Users7.EOF AND Trim(Request.Form("Area_Mgr" & x)) <> "" Then
errorArray(errorCount) = Trim(Request.Form("Area_Mgr" & x))
errorCount = errorCount + 1
End If
else
Response.Write x & " - Has been changed <BR><BR>"
Call updateAreaManager()
End If
If Not rs_Users3.EOF Then
mySQL8 = "SELECT Manage_Area_Name FROM CJI_AreaMgrs WHERE Manage_Area_Name = '" & Trim(Request.Form("Manage_Area_Name" & x)) & "' AND Area_ID != '" & Trim(Request.Form("Area_ID" & x)) & "';"
Set rs_Users8 = Con.Execute( mySQL8 )
if NOT rs_Users8.EOF AND Trim(Request.Form("Manage_Area_Name" & x)) <> "" Then
errorArray(errorCount) = Trim(Request.Form("Manage_Area_Name" & x))
errorCount = errorCount + 1
End If
else
Response.write x & " - Has been changed <BR><BR>"
Call updateArea()
End If
elseIf TableName = "CJI_RegionMgrs" Then
mySQL4 = "SELECT * FROM CJI_RegionMgrs WHERE Regional_Mgr_Name = '" & Trim(Request.Form("Regional_Mgr_Name" & x)) & "';"
response.write mysql4
Set rs_Users4 = Con.Execute( mySQL4 )
mySQL5 = "SELECT * FROM CJI_RegionMgrs WHERE Management_Region_Name = '" & Trim(Request.Form("Management_Region_Name" & x)) & "';"
response.write mysql5
Set rs_Users5 = Con.Execute( mySQL5 )
If Not rs_Users4.EOF Then
mySQL10 = "SELECT Regional_Mgr_Name FROM CJI_RegionMgrs WHERE Regional_Mgr_Name = '" & Trim(Request.Form("Regional_Mgr_Name" & x)) & "' AND Regional_Mgr_ID != '" & Trim(Request.Form("Regional_Mgr_ID" & x)) & "';"
Set rs_Users10 = Con.Execute( mySQL10 )
if NOT rs_Users10.EOF AND Trim(Request.Form("Management_Region_Name" & x)) <> "" Then
errorArray(errorCount) = Trim(Request.Form("Regional_Mgr_Name" & x))
errorCount = errorCount + 1
End If
else
Response.Write x & " - Has been changed <BR><BR>"
Call updateRegionalManager()
End If
If Not rs_Users5.EOF Then
mySQL9 = "SELECT Management_Region_Name FROM CJI_RegionMgrs WHERE Management_Region_Name = '" & Trim(Request.Form("Management_Region_Name" & x)) & "' AND Regional_Mgr_ID != '" & Trim(Request.Form("Regional_Mgr_ID" & x)) & "';"
Set rs_Users9 = Con.Execute( mySQL9 )
if NOT rs_Users9.EOF AND Trim(Request.Form("Management_Region_Name" & x)) <> "" Then
errorArray(errorCount) = Trim(Request.Form("Management_Region_Name" & x))
errorCount = errorCount + 1
End If
else
Response.write x & " - Has been changed <BR><BR>"
Call updateRegion()
End If
End If
End If
Next
Function updateID()
mySQL = "SELECT * FROM CJI_AreaMgrs;"
response.write mysql
Set rs_Users = Con.Execute( mySQL )
IF Not rs_Users.EOF then
sqlupdate = "UPDATE CJI_AreaMgrs SET Regional_Mgr_ID = '" & Trim(Request.Form("Regional_Mgr_ID" & x)) & "' WHERE Area_ID = '" & Trim(Request.Form("Area_ID" & x)) & "';"
Con.Execute( sqlupdate )
End If
End Function
Function updateArea()
mySQL = "SELECT * FROM CJI_AreaMgrs;"
response.write mysql
Set rs_Users = Con.Execute( mySQL )
If Not rs_Users.EOF Then
sqlUpdate = "UPDATE CJI_AreaMgrs SET Manage_Area_Name = '" & Trim(Request.Form("Manage_Area_Name" & x)) & "' WHERE Area_ID = '" & Trim(Request.Form("Area_ID" & x)) & "';"
Con.Execute(sqlUpdate)
End If
End Function
Function updateAreaManager()
mySQL = "SELECT * FROM CJI_AreaMgrs;"
response.write mysql
Set rs_Users = Con.Execute( mySQL )
If Not rs_Users.EOF Then
sqlUpdate = "UPDATE CJI_AreaMgrs SET Area_Mgr = '" & Trim(Request.Form("Area_Mgr" & x)) & "' WHERE Area_ID = '" & Trim(Request.Form("Area_ID" & x)) & "';"
Con.Execute(sqlUpdate)
End If
End Function
Function updateRegionalManager()
mySQL = "SELECT * FROM CJI_RegionMgrs;"
response.write mySQL
Set rs_Users = Con.Execute( mySQL )
If Not rs_Users.EOF Then
sqlUpdate = "UPDATE CJI_RegionMgrs SET Regional_Mgr_Name = '" & Trim(Request.Form("Regional_Mgr_Name" & x)) &"' WHERE Regional_Mgr_ID = '" & Trim(Request.Form("Regional_Mgr_ID" & x)) & "';"
Con.Execute(sqlUpdate)
End If
End Function
Function updateRegion()
mySQL = "SELECT * FROM CJI_RegionMgrs;"
response.write mySQL
Set rs_Users = Con.Execute( mySQL )
If Not rs_Users.EOF Then
sqlUpdate = "UPDATE CJI_RegionMgrs SET Management_Region_Name = '" & Trim(Request.Form("Management_Region_Name" & x)) &"' WHERE Regional_Mgr_ID = '" & Trim(Request.Form("Regional_Mgr_ID" & x)) & "';"
Con.Execute(sqlUpdate)
End If
End Function
Function updateAreaManagerJapanese()
mySQL = "SELECT * FROM CJI_AreaMgrs;"
response.write mysql
Set rs_Users = Con.Execute( mySQL )
If Not rs_Users.EOF Then
sqlUpdate = "UPDATE CJI_AreaMgrs SET Area_MgrJP = '" & Trim(Request.Form("Area_MgrJP" & x)) & "' WHERE Area_ID = '" & Trim(Request.Form("Area_ID" & x)) & "';"
Con.Execute(sqlUpdate)
End If
End Function
Function updateRegionalManagerJapanese()
mySQL = "SELECT * FROM CJI_RegionMgrs;"
response.write mySQL
Set rs_Users = Con.Execute( mySQL )
If Not rs_Users.EOF Then
sqlUpdate = "UPDATE CJI_RegionMgrs SET Regional_Mgr_Name_JP = '" & Trim(Request.Form("Regional_Mgr_Name_JP" & x)) &"' WHERE Regional_Mgr_ID = '" & Trim(Request.Form("Regional_Mgr_ID" & x)) & "';"
Con.Execute(sqlUpdate)
End If
End Function
Session("errorArray") = errorArray
Session("errorCount") = errorCount
Response.Redirect "maslist.asp?table=" & TableName
%>
Thanks guys. |
|
#8
|
||||
|
||||
|
sorry, that's far beyond what you asked in your first post here.
in there you posted rather short block of client side code and asked for help converting this to VBScript. now you ask much much more, and server side related.. if the first post is relevant post what you have and we'll try to help you with the rest, otherwise please start new thread with your new problem and full details including error message and the relevant code causing it. |
|
#9
|
|||
|
|||
|
Oh man, I tried to do that and people were saying not to. Alright, I'll try again.
|
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Incremental Variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|