Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code producing incorrect values

Status
Not open for further replies.

janise

Technical User
May 25, 2003
161
US
I don't know where I am screwing up here but this code below, when I run it, on the empID column, 2 values are generated:

EmpID = 12,2351 which means that values for org and empid are being stored in empid column.
The org value and the Emp value are being passed to the empID column.
The org column is getting passed the correct value.
I believe the error is occuring here:

IF flag=1 then
myArray=split(request.Form("EmpID"),",")
iID=Cint(myArray(0))
iOrg=myArray(1)
End if
and here:
<option value=&quot;<%=ID%>,<%=Org%>&quot;<%if iID=rs(&quot;empID&quot;)then%>selected<%end if%>><%=FullName%></option>

I tried removing <%=org%> but I get an error that number of arguments is wrong.
When I tried to change array code to this:

IF flag=1 then
iID=request.Form(&quot;EmpID&quot;)
End if
No more values are being passed.
Can someone, please see if you can help.
Below is some of the code.
Thanks,
<%
Set con=Server.CreateObject(&quot;ADODB.Connection&quot;)
dbPath=&quot;dsn=safety&quot;
con.Open dbPath
Const adOpenStatic = 3
Const adUseClient = 3
Const adLockPessimistic = 2

set rs=server.CreateObject(&quot;ADODB.Recordset&quot;)

sub sql(byval cmd)
if rs.State=1 then rs.Close
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.LockType = adLockPessimistic
rs.Source = cmd
rs.ActiveConnection = Con 'The record set needs to know what connection to use.
rs.Open
end sub

IF request.Form(&quot;flag&quot;) <> &quot;&quot; then
flag=request.Form(&quot;flag&quot;)
End if
IF flag=1 then
myArray=split(request.Form(&quot;EmpID&quot;),&quot;,&quot;)
iID=Cint(myArray(0))
iOrg=myArray(1)
End if
%>

<SCRIPT LANGUAGE=javascript>
<!--

function submitName(){
var objForm = document.forms[0];
//objForm.elements['Org'].selectedIndex=0;
//objForm.elements['Division'].selectedIndex=0;
objForm.submit();
}
function GoToProcessingPage()
{
var objForm = document.forms[0];
objForm.action=&quot;frmSelect.asp&quot;;
objForm.submit();
}

//-->
</SCRIPT>

</HEAD>
<BODY>
<center>
<FORM action=&quot;frmWorkmans.asp&quot; method=&quot;POST&quot; name=&quot;myForm&quot;>
<input type=&quot;hidden&quot; name=&quot;flag&quot; value=&quot;1&quot;>
<SELECT name=&quot;EmpID&quot; onChange=&quot;submitName()&quot;>
<option value=&quot;&quot;>-- select name --</option>
<%
sql &quot;SELECT empID,ORG,FName,LName FROM theEmp Order By FName&quot;
while not rs.EOF
FullName=rs(&quot;FName&quot;) & &quot; &quot; & rs(&quot;LName&quot;)
ID=rs(&quot;empID&quot;)
Org=rs(&quot;Org&quot;)
%>
<option value=&quot;<%=ID%>,<%=Org%>&quot; <%if iID=rs(&quot;empID&quot;)then%>selected<%end if%>><%=FullName%></option>
<%
rs.MoveNext
wend
%>
</SELECT>

<br>
<%if flag=1 then%>
<SELECT name=&quot;Org&quot; >
<%
sql &quot;SELECT Org FROM theEmp where empID =&quot; & iID
while not rs.EOF
Org=rs(&quot;Org&quot;)
%>
<option value=&quot;<%=Org%>&quot;><%=rs(&quot;Org&quot;)%></option>
<%
rs.MoveNext
wend
%>
</SELECT>
<%end if%>
<br>
<%if flag=1 then%>
<SELECT name=&quot;Division&quot;>
<%
sql &quot;SELECT DISTINCT Division FROM theEmp where Org=&quot;& iOrg
while not rs.EOF
Division=rs(&quot;Division&quot;)
%>
<option value=&quot;<%=Division%>&quot; ><%=Division%></option>
<%
rs.MoveNext
wend
%>
</SELECT>
<%end if%>
 
Should be <%=iID%> and <%=iOrg%> with &quot;i&quot; as first letter.

________
George, M
 
i was thinking that too, but look closer and you'll see:
Code:
    ID=rs(&quot;empID&quot;)
    Org=rs(&quot;Org&quot;)
%>
>
    <option value=&quot;<%=ID%>,<%=Org%>&quot; <%if iID=rs(&quot;empID&quot;)then%>selected<%end if%>><%=FullName%></option>

ion de code snippet.
&quot;on the empID column, 2 values are generated: EmpID = 12,2351 &quot;


i see a difference in the buildup of the <OPTION>'s:

a) <option value=&quot;<%=ID%>,<%=Org%>&quot;
b) <option value=&quot;<%=Org%>&quot;><%=rs(&quot;Org&quot;)%>


a) results in Values like 12,2351 i suppose, while b) will give 2351,2351.

maybe a little more clarification from janice here?










hth,
Foxbox
ttmug.gif
 
Thanks to all, I have resolved the problem.
First, I added this line:

iOrg=rs(&quot;Org&quot;)
to these lines:

<%
sql &quot;SELECT Org FROM theEmp where empID =&quot; & iID
while not rs.EOF
Org=rs(&quot;Org&quot;)
%>

Even with this new line added, I was still seeing 2 values added to empid.
So on the processing page, I added 2 lines of code:
arr = split(request.form(&quot;empid&quot;)
arr=(0). This way, only one value was getting passed.
Yes, you guys are on the right track with your super problem solving skills.
Thanks for trying to help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top