...

View Full Version : how to avoid the page refresh when select button



tanpl3
10-31-2005, 10:13 AM
Every time, user must select the currency code first, then the system will display all the group name where the currency is equal to the selected currency; then user will select the group name from the option; then system will display all the group description belongs to the group name; user will select the group desciption to perform some operation. My problem here is, every time user select the currency, the page will refresh in order to let the system filter the group names belongs to the currency, after that, the page will refresh again once the group name is onchange...and so on. Is there anyway, other than using refresh method on this case?
here is my code

function passcur(curv)
{
document.location = "./HRPosting.asp?cury="+curv.value;
}

function passgrp(curgrp, xf)
{
curgp="+curg+"&tid="+cid+"&cury="+xf.cboCurrcy.value;
document.location = "./HRPosting.asp?curgp="+curgrp.value.replace("&", "amp;")+"&cury="+xf.cboCurrcy.value;
}

function passdsc(curdesc, xf)
{
temp = curdesc.value;
ss = temp.split(";");
cdesc =ss[0];
tran = ss[1];
document.location = "./HRPosting.asp?trnid="+tran+"&curds="+cdesc.replace("&", "amp;")+"&cury="+xf.cboCurrcy.value+"&curgp="+xf.cbotrngrp.value.replace("&", "amp;");
}

<table id="myrow1" style="display:inline" width="765">
<tr>
<td height="29" width="528">
<input type="button" onmouseover="this.style.cursor='hand';" name="btnSeach" value=" Search " onclick="PassTemplate(document.start)" style="color: #000000; font-style: italic; font-weight: bold; border: 1px solid #000000; background-color: #FFFFFF">
<select name="cboCurrcy" class ="cb1" onchange="passcur(this)">
<option value="<%if request("cury") <> "" then response.write request("cury") else response.write "%" end if%>" selected><%if request("cury") <> "" then response.write request("cury") else response.write "" end if%></option>
<%
'cur = "select distinct curcode, tranid from tbdtemplate where curcode <> '"&request("cury")&"' and src = '"&session("hrtype")&"' order by curcode"
cur = "select distinct curcode from tbdtemplate where curcode <> '"&request("cury")&"' and src = '"&session("hrtype")&"' order by curcode"
rs1.open cur, con, 3
if rs1.eof <> true and rs1.bof <> true then
do while not rs1.eof
%>
<option value="<%=rs1("curCode")%>"><%=rs1("curCode")%></option>
<%
rs1.moveNext
Loop
rs1.close
end if
%>
</select>&nbsp;
<select name="cbotrngrp" class ="cb1" onchange="passgrp(this, document.start)">
<option value="<%if request("curgp") <> "" then response.write replace(request("curgp"), "amp;", "&") else response.write "%" end if%>" selected><%if request("curgp") <> "" then response.write replace(request("curgp"), "amp;", "&") else response.write "" end if%></option>
<%
grps=replace(request("curgp"),"amp;", "&")
'Tgrp = "select distinct TranGroup, tranid from tbdtemplate where tranid ='"&request("tid")&"' and TranGroup <> '"&request("curgp")&"' and src = '"&session("hrtype")&"' order by TranGroup"
Tgrp = "select distinct TranGroup from tbdtemplate where curcode ='"&request("cury")&"' and TranGroup <> '"&replace(grps,"'","''")&"' and src = '"&session("hrtype")&"' order by TranGroup"
rs2.open Tgrp, con, 3
if rs2.eof <> true and rs2.bof <> true then
do while not rs2.eof
%>
<option value="<%=trim(rs2("trangroup"))%>"><%=trim(rs2("trangroup"))%></option>
<%
rs2.moveNext
Loop
rs2.close
end if
%>

</select>&nbsp;
<select name="cbogrpdesc" class ="cb1" onchange="passdsc(this, document.start)">
<option value="<%if request("curds") <> "" then response.write replace(request("curds"), "amp;", "&") else response.write "%" end if%>" selected><%if request("curds") <> "" then response.write replace(request("curds"), "amp;", "&") else response.write "" end if%></option>
<%
grps=replace(request("curgp"),"amp;", "&")
grpsd=replace(request("curds"),"amp;","&")

'Tgrpd = "select distinct groupdesc, TranID from tbdtemplate where TranID = '"&request("tid")&"'"
Tgrpd = "select distinct groupdesc, TranID from tbdtemplate where curcode = '"&request("cury")&"'"
Tgrpd = Tgrpd & " and trangroup = '"&replace(grps,"'","''")&"'"
Tgrpd = Tgrpd & " and groupdesc <> '"&replace(grpsd,"'","''")&"' order by groupDesc"

rs3.open Tgrpd, con, 3
if rs3.eof <> true and rs3.bof <> true then
do while not rs3.eof
%>
<option value="<%=trim(rs3("groupdesc")) & ";" & trim(rs3("TranID"))%>"><%=trim(rs3("groupdesc"))%></option>
<%
rs3.moveNext
Loop
rs3.close
end if
%>
</select></td>
</table>

Pyth007
10-31-2005, 04:01 PM
I don't know % ASP %, but I think its the same / similar problem that others are having... You basically want some type of remote scripting scheme that allows you to load info using a hidden iframe / frame and then having javascript post that info dynamically onto the page. Try looking-up "remote scripting", "XHTML", and "AJAX"; there are some tutorials on that which might help...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum