PDA

View Full Version : javascript function with asp


twocool
05-07-2003, 11:17 AM
i got one problem with the asp

i want it to execute this way

UPDATE Requests SET ReqStatus= 'Approve', RejRemarks= 'test' where ReqNo= 'RQ2003050010'


but in the end it is showing this way

UPDATE Requests SET ReqStatus= 'ReqStatus0', RejRemarks= 'RejRemarks0' where ReqNo= 'RQ2003050010'


this is my code....

<script language="javascript">

function submit_form(ReqNo, currentEle) {
document.form2.ReqNo.value = ReqNo;

document.form2.ReqStatus.value ="ReqStatus"+ currentEle +"";
document.form2.RejRemarks.value ="RejRemarks"+ currentEle +"";

//document.form2.RejRemarks.value = document.form2.RejRemarks.value;
//document.form2.ReqStatus.value = " '+ currentEle +' ReqStatus<%=counter%>";
//document.form2.RejRemarks.value = " '+ currentEle +' RejRemarks<%=counter%>";

document.form2.action = "approve_action.asp"
document.form2.submit()
}

</script>

<% sql= "SELECT * from Requests WHERE ReqtrEmail = '"&Request.ServerVariables("LOGON_USER")&"@singtel.com' AND ReqStatus = 'New'"
set rs = MSCS.Execute(sql)
counter = 0
%>

<form name="form2" method="post">
<table width="100%" border="0" cellspacing=0 align="center">

<tr style="background-color:#EEEEEE;" class="header3">
<td width="15%" height="22">Request No</td>
<td width="25%" height="22">Requestor Name</td>
<td width="15%" height="22">Application System</td>
<td width="20%" height="22">Request Title</td>
<td width="10%" height="22">Request Date</td>
<td width="10%" height="22">Desired Date</td>
<td width="15%" height="22">Action</td>
</tr>

<%Do While Not rs.EOF%>
<tr style="background-color:#FFFFCC;" onmouseover="this.style.backgroundColor='#ffcc99';" onmouseout="this.style.backgroundColor='#FFFFCC';" class="text">

<td width="15%"><a href="approve_display.asp?ReqNo=<%=rs("ReqNo")%>" target="_blank", width=500,height=400><%=rs("ReqNo")%></a></td>
<!--input type="hidden" name="ReqNoHF" value="<%=rs("ReqNo")%>"-->
<td width="25%"><span class="txtblack12"><%=rs("Reqtr")%></span></td>

<td width="15%"><span class="txtblack12"><%=rs("AppnId")%></span></td>

<td width="20%"><span class="txtblack12"><%=rs("ReqTitle")%></span></td>

<td width="10%"><span class="txtblack12"><%=Day(rs("ReqDt") )%>/<%=Month(rs("ReqDt") )%>/<%=Year(rs("ReqDt") )%> <%'=rs("ReqDt")%></span></td>

<td width="10%"><span class="txtblack12"><%=Day(rs("DesiredDt") )%>/<%=Month(rs("DesiredDt") )%>/<%=Year(rs("DesiredDt") )%> <%'=rs("DesiredDt")%></span></td>


<td width="15%">
<select name="ReqStatus<%=counter%>">


<%
sql="Select ReqStatus from ReqStatusRef where SeqNo='2' or SeqNo='98'"
set rs1 = MSCS.Execute(sql)

if not rs1.eof then
do
%>
<option value="<%=rs1("ReqStatus")%>"><%=rs1("ReqStatus")%></option>
<%
rs1.movenext
loop until rs1.eof
end if
%>
</select>
</td>
</tr>

<tr>
<td width="15%">Reasons For Rejection:</td>
<td width="25%">
<textarea rows="3" cols="45" name="RejRemarks<%=counter%>" onKeyUp="max_count();" class="txtblack12"></textarea>
</td>

<td width="13%">
<input type="button" onclick="submit_form('<%=rs("ReqNo")%>', '<%=counter%>' )" name=Submit value="Submit">
<!--input type="submit" onclick="javascript:submit_form('<%=ReqNo%>','<%=ReqStatus%>','<%=RejRemarks%>','update')" name=Submit value="Submit" ID="Submit1"-->
<!--input type="submit" name="Submit" value="Submit"-->
<%rs.MoveNext
counter = counter + 1
%>
<%loop%>
</td>
</tr>
</table>
<input type="hidden" name="ReqNo" value="">
<input type="hidden" name="ReqStatus" value="">
<input type="hidden" name="RejRemarks" value="">
</form>
<%
rs.close
set rs=nothing
%>

Roy Sinclair
05-07-2003, 04:38 PM
These two lines in your submit function are setting the values you are seeing:


document.form2.ReqStatus.value ="ReqStatus"+ currentEle +"";
document.form2.RejRemarks.value ="RejRemarks"+ currentEle +"";


Try just removing those lines.

twocool
05-08-2003, 04:09 AM
UPDATE Requests SET ReqStatus= '', RejRemarks= '' where ReqNo= 'RQ2003050010'

after i removed those lines its shows this.....
but i need the reqstatus to show APPROVED OR REJECTED


the seq no=2 means Approved
the seq no=98 means Rejected.

how should i do it bro.. need r help

Roy Sinclair
05-08-2003, 03:10 PM
Ok I think I see what you're doing a little more clearly now, the problem is still with the same two lines but removing them wasn't the right answer, changing them as below should help:


document.form2.ReqStatus.value = document.form2["ReqStatus"+ currentEle].value;
document.form2.RejRemarks.value = document.forms2["RejRemarks"+ currentEle].value;

twocool
05-09-2003, 01:59 AM
bro thanks man.. i really owe u one...... u helped me a lot in this... thanks ... really thank u.. man....:thumbsup: