PDA

View Full Version : please help me with this...page getting refreshed automatically


vani_ge
12-13-2005, 06:29 PM
Hi,

I have a dropdownbox in my page and the selected value of it is to be sent to a java function .so that i can send that variable to the same page.

Later using request.querystring() method i had that variable used in a sql query to populate a textbox with the result set.The problem is ....

i have a alert stmt in the java script function and only after clicking that alert box i am having the result i the textbox.If that alert is removed inothing is happening.

another issue is....after i click that alert box and after the data is being displayed in the textbox the page is loading itself again and all the data is lost

below is the code for that.........Please help me in this............


<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<style type="text/css" media="all">@import "../inc/uopstu.css";</style>
<SCRIPT language="JavaScript" type="text/javascript">
<!--
var checkflag = "false";

sub showform
<script>
<% if Request.querystring("Action")="" then %>
function OOchange(form)
{

if(document.f1.Campus.options[document.f1.Campus.selectedIndex].value)
{
var Campus="";
Campus=document.f1.Campus.options[document.f1.Campus.selectedIndex].value;
alert(Campus);
(document.f1.action= 'svr_temp.asp?Action=1 & campus=' + Campus);
document.f1.method = "POST";
document.f1.submit();
flag="true";
hidden_Team_Auto.style.display='block';
}



}
<% else %>
alert("<%= Request.QueryString("campus")%>);
</script>

<tr id="hidden_Division" style="display:none;">
<TD align=right width=50% height="22">Select a Campus Name</I></TD>
<TD align=left height="48">
<SELECT Name="Campus" Size="1" onChange="OOchange(this.form)" ID="Select2">
<% Do While NOT MyRS1.EOF %>
<option Value="<%= MyRS1("CampusName") %>"><%= MyRs1("CampusName")%></option>
<% MyRS1.MoveNext
loop %>
</SELECT>
</TD>
</tr>
<!--#include File="../inc/LSDevConn.asp"-->
<%
'if request.querystring("Campus") <> "" then
if campus<> "" then
'response.Write("hi")
'response.End
'MYSQL2="Select distinct substring(collector_name,13,5) AS Code from svr_compare where substring(collector_name,1,4)= (select Collector_Code from CampCollCode where Division='"& request.QueryString("campus")& "')"
MYSQL2="Select distinct substring(collector_name,13,5) AS Code from svr_compare where substring(collector_name,1,4)= (select Collector_Code from CampCollCode where Division='"& campus & "')"
Set MyRs2=MyConn.Execute(MySQL2)
Dim str
str=MyRS2("Code")
MyRS2.MoveNext
Do While NOT MyRS2.EOF
str=str & "," & MyRS2("Code")
MyRS2.MoveNext
loop
end if
%>
<TR id="hidden_Team_Auto" style="display:none;">
<TD align=left height="48">
<INPUT type=text name=TeamNumAuto maxlength=25 size=15 value= "<% =str %>" ID="Text1">
</TD>
</TR>
</table>
</form>
</html>

end sub

PhotoJoe47
12-13-2005, 08:39 PM
I'm not sure, (i'm just now learning Studio VB Express) but I think you are mixing your VB script inside of the Javascript tags and I don't think that will work.

vani_ge
12-13-2005, 09:44 PM
hi,

Now i have removed the alert statement and have set few things....this time i tried to send the variable with window.location instead of document.for.actionmethod.Now for the first time nothing is happening.From the second time when ever i select a value in the dropdown box, the textbox is being populated with the result but immediately the page is getting loaded again and all the data is being lost......please help....here is the code............


<%@ LANGUAGE="VBSCRIPT" %>

sub show form
</SCRIPT>
<TITLE>SVR StartDate Selection</TITLE>
</HEAD>
<BODY >
<FORM method=post name=f1 ID="Form1">
function OOchange()
{
var Campus="";
if(document.f1.Campus.options[document.f1.Campus.selectedIndex].value)
{
Campus=document.f1.Campus.options[document.f1.Campus.selectedIndex].value;

window.location = 'svr_temp.asp?Campus=' + Campus;
hidden_Team_Auto.style.display='block';
}

}

-->
</SCRIPT>
<TITLE>SVR StartDate Selection</TITLE>
</HEAD>
<BODY >
<FORM method=post name=f1 ID="Form1">
</tr>

<tr id="hidden_Division" style="display:none;">
<TD align=right width=50% height="22">Select a Campus Name</I></TD>
<TD align=left height="48">
<SELECT Name="Campus" Size="1" onChange="OOchange()" ID="Select2">
<% Do While NOT MyRS1.EOF %>
<option Value="<%= MyRS1("CampusName") %>"><%= MyRs1("CampusName")%></option>
<% MyRS1.MoveNext
loop %>
</SELECT>
</TD>
</tr>
<!--#include File="../inc/LSDevConn.asp"-->
<%
if request.querystring("Campus") <> "" then
'response.Write("hi")
'response.End
MYSQL2="Select distinct substring(collector_name,13,5) AS Code from svr_compare where substring(collector_name,1,4)= (select Collector_Code from CampCollCode where Division='"& request.QueryString("Campus")& "')"
Set MyRs2=MyConn.Execute(MySQL2)
Dim str
str=MyRS2("Code")
MyRS2.MoveNext
Do While NOT MyRS2.EOF
str=str & "," & MyRS2("Code")
MyRS2.MoveNext
loop
end if
%>
<TR id="hidden_Team_Auto" style="display:none;">
<TD align=left height="48">
<INPUT type=text name=TeamNumAuto maxlength=25 size=15 value= "<% =str %>" ID="Text1">
</TD>

ens sub