|
 |
asp_web_howto thread: Option control
Message #1 by "Steve Read" <Steve.Read8787@b...> on Thu, 17 May 2001 20:54:52 +0100
|
|
Thank you Tom for replying
I think I know what you mean. I found this code on the microsoft
website.
I've been trying to associate it with my code, but I'm confused because
I'm
using the TYPE =3Dsubmit button, but here it uses TYPE =3Dbutton. I
tried using
the onsubmit method, but again it's not associating. How do I do it?
<HTML>
<SCRIPT LANGUAGE=3D"VBSCRIPT">
Sub ShowVals
Dim SelStr
For i =3D 0 to Form1.myselect.length - 1
If Form1.myselect.options(i).selected =3D True Then
selstr =3D selstr & Form1.myselect.options(i).value & chr(10)
End If
Next
MsgBox SelStr,,"Selected Item(s)"
End Sub
</SCRIPT>
<BODY>
<FORM NAME=3D"Form1">
<SELECT MULTIPLE NAME=3D"MySelect">
<OPTION VALUE=3D"10">Option 1 (10)
<OPTION VALUE=3D"20">Option 2 (20)
<OPTION VALUE=3D"30">Option 3 (30)
</SELECT>
<INPUT TYPE=3DBUTTON onClick=3D"ShowVals()" VALUE=3D"Show
Value(s)">
</FORM>
</BODY>
</HTML>
----- Original Message -----
From: TomMallard <mallard@s...>
To: ASP Web HowTo <asp_web_howto@p...>
Sent: Thursday, May 17, 2001 3:44 PM
Subject: [asp_web_howto] Re: Combo Box problem
> Quick scan of the code but I don't see where you change selectedindex,
you
> have a submit button so it's never changed. Think you need a regular
button
> with an onclick function which resets the selectedindex before
submitting.
Message #2 by "TomMallard" <mallard@s...> on Fri, 18 May 2001 08:35:26 -0700
|
|
Hmmm, OK, this may help...you do need the type=button, not type=submit, the
code you found gets what's selected but doesn't set selectedIndex which is
what I think you need to do.
If Form1.myselect.options(i).selected = True Then
Form1.myselect.selectedIndex = i
......
The first line finds what's selected and the next sets the selectedIndex to
i. Hopefully this is all you'll need to do since the page isn't getting
reloaded, it's just getting focus. If this doesn't work, you'll need to
store this value in a hidden field and reset selectedIndex to it using the
onfocus even for the body tag.
tom
----- Original Message -----
From: "Steve Read" <Steve.Read8787@b...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Thursday, May 17, 2001 12:54 PM
Subject: [asp_web_howto] Option control
> Thank you Tom for replying
> I think I know what you mean. I found this code on the microsoft
> website.
> I've been trying to associate it with my code, but I'm confused because
> I'm
> using the TYPE =3Dsubmit button, but here it uses TYPE =3Dbutton. I
> tried using
> the onsubmit method, but again it's not associating. How do I do it?
>
>
>
> <HTML>
> <SCRIPT LANGUAGE=3D"VBSCRIPT">
>
> Sub ShowVals
> Dim SelStr
> For i =3D 0 to Form1.myselect.length - 1
> If Form1.myselect.options(i).selected =3D True Then
> selstr =3D selstr & Form1.myselect.options(i).value & chr(10)
> End If
> Next
> MsgBox SelStr,,"Selected Item(s)"
> End Sub
>
> </SCRIPT>
>
> <BODY>
>
> <FORM NAME=3D"Form1">
> <SELECT MULTIPLE NAME=3D"MySelect">
> <OPTION VALUE=3D"10">Option 1 (10)
> <OPTION VALUE=3D"20">Option 2 (20)
> <OPTION VALUE=3D"30">Option 3 (30)
> </SELECT>
>
> <INPUT TYPE=3DBUTTON onClick=3D"ShowVals()" VALUE=3D"Show
> Value(s)">
> </FORM>
>
> </BODY>
> </HTML>
>
>
> ----- Original Message -----
> From: TomMallard <mallard@s...>
> To: ASP Web HowTo <asp_web_howto@p...>
> Sent: Thursday, May 17, 2001 3:44 PM
> Subject: [asp_web_howto] Re: Combo Box problem
>
>
> > Quick scan of the code but I don't see where you change selectedindex,
> you
> > have a submit button so it's never changed. Think you need a regular
> button
> > with an onclick function which resets the selectedindex before
> submitting.
>
>
Message #3 by "Steve Read" <Steve.Read8787@b...> on Mon, 21 May 2001 16:47:01 +0100
|
|
Hi Tom,
Still trying to sort this problem out. If you recall I have an option
control and my code below looks to find what index value in the option
control was chosen. I do this by :
m_nChart =3D Request.QueryString("Chart")
Now, I want the text value in the option control to display what was
chosen.
This is where it presently defaults to the the first item in the list as
I
want a particular graph displayed when the asp loads for the first time.
The
code tests for the value held in the variable called m_nChart via a CASE
statement. It is here I feel I can control the option text value, but it
gives me an error either variable not defined or if I remove OPTION
EXPLICIT
it returns object required. The other thing is with regard to having a
submit button or an ordinary button. I feel I got to have a submit
button
here because I'm firing an ASP and need to use the GET. An ordinary
button would
not fire my asp. (I stand corrected)
I could still however run a procedure prior to the ASP running. I tried
Sub choice_On_Submit
Msgbox("Test")
End Sub
but it does not fire. I'm getting nowhere fast!!
Hope you can help. (or anyone else)
steve
Select Case m_nChart
Case 0
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_TO"
m_ser.Line.Color =3D RGB(255,0,0)
choice.chart.options(0).text =3D choice.chart.options(0).value
FormatChart m_cht, "TURNOVER - (Sales)", "Value", "Months", "=A3#,##"
Case 1 .........blah blah...
HERE IS THE CODE SO FAR
<%@ Language=3DVBScript %>
<% Option Explicit %>
<html>
<head>
<title>
Company Graph containing 12months data</title>
</head>
<body>
<%
Sub FormatChart(cht, sTitle, sValTitle, sCatTitle, sValNumFmt)
Dim ax 'Temp WCAxis object
Dim fnt 'Temp OWCFont object
Dim c 'Constants object
set c =3D cht.Parent.Constants
cht.HasTitle =3D True
cht.Title.Caption =3D sTitle
set fnt =3D cht.Title.Font
fnt.Name =3D "Tahoma"
fnt.Size =3D 10
fnt.Bold =3D True
For Each ax in cht.Axes
if ax.Type =3D c.chValueAxis then
ax.HasTitle =3D True
ax.Title.Caption =3D sValTitle
set fnt =3D ax.Title.Font
fnt.Name =3D "Tahoma"
fnt.Size =3D 8
fnt.Bold =3D True
ax.NumberFormat =3D sValNumFmt
else
ax.HasTitle =3D True
ax.Title.Caption =3D sCatTitle
set fnt =3D ax.Title.Font
fnt.Name =3D "Tahoma"
fnt.Size =3D 8
fnt.Bold =3D True
end if
Next
End Sub
Sub CleanUpGIF(strpath)
dim objfs
dim objfolder
dim gif
set objfs=3Dserver.createobject("scripting.filesystemobject")
set objfolder=3Dobjfs.getfolder(strpath)
for each gif in objfolder.files
if instr(gif.name, ".gif") >0 and datediff("n",gif.datelastmodified,
now)
>5 then
objfs.deletefile strpath & "\" & gif.name, true
end if
next
set objfolder =3D nothing
set objfs =3D nothing
end sub
Dim m_nChart 'Index of desired data set
Dim m_cspace 'OWC Chartspace object reference
Dim m_cht 'WCChart object reference
Dim m_ser 'WCSeries object reference
Dim c 'Constants object reference
Dim m_sFilePath 'Root file path for GIF
Dim m_ct 'Generic loop counter
Dim strConnect
Dim oconn
Dim SQL
Dim rs
Dim strpath
strpath =3D server.mapPath("/graphs")
strConnect =3D "PROVIDER=3DSQLOLEDB;" & _
"SERVER=3D(local);" & _
"DATABASE=3DPOFFLE;" & _
"UID=3Dsa;PWD=3D"
set oconn =3D server.createobject("ADODB.connection")
oconn.open strconnect
SQL=3D"SELECT * FROM Graphdata ORDER BY MONTH1 DESC"
m_nChart =3D Request.QueryString("Chart")
If IsEmpty(m_nChart) Then m_nChart =3D 0
set m_cspace =3D server.CreateObject("OWC.Chart")
set m_cht =3D m_cspace.Charts.Add()
set c =3D m_cspace.Constants
Set rs =3D Server.CreateObject("ADODB.Recordset")
rs.cursorlocation =3D 3
rs.open SQL,oconn,3
set m_cspace.datasource =3D rs
Select Case m_nChart
Case 0
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_TO"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "TURNOVER - (Sales)", "Value", "Months", "=A3#,##"
Case 1
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_TXS"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "TRANSACTIONS - (Sales)", "Value", "Months", "#,##"
Case 2
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_RFNDS_TO"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "TURNOVER - (Refunds)", "Value", "Months", "=A3#,##"
Case 3
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_RFNDS_TXS"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "TRANSACTIONS - (Refunds)", "Value", "Months", "#,##"
Case 4
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_MSC"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "GROSS INCOME - (Merchant Service Charge)", "Value",
"Months", "=A3#,##"
Case 5
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_INTERCHANGE"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "INTERCHANGE", "Value", "Months", "=A3#,##"
Case 6
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "NI"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "NET INCOME", "Value", "Months", "=A3#,##"
End Select
%>
<form action=3D"GetChart.asp" method=3D"GET" name=3D"choice">
Select a Report: <select name=3D"Chart">
<% if m_nChart =3D 0 then %>
<option selected value=3D"0">TURNOVER - (Sales)</option>
<option value=3D"1">TRANSACTIONS - (Sales)</option>
<option value=3D"2">TURNOVER - (Refunds)</option>
<option value=3D"3">TRANSACTIONS - (Refunds)</option>
<option value=3D"4">GROSS INCOME - (Merchant Service
Charge)</option>
<option value=3D"5">INTERCHANGE</option>
<option value=3D"6">NI</option>
<%else%>
<option value=3D"0">TURNOVER - (Sales)</option>
<option value=3D"1">TRANSACTIONS - (Sales)</option>
<option value=3D"2">TURNOVER - (Refunds)</option>
<option value=3D"3">TRANSACTIONS - (Refunds)</option>
<option value=3D"4">GROSS INCOME - (Merchant Service
Charge)</option>
<option value=3D"5">INTERCHANGE</option>
<option value=3D"6">NI</option>
<% end if %>
</select> <input type=3D"Submit" value=3D"Go" id=3D"btnSubmit"
name=3D"btnSubmit">
</form>
<hr>
<%
m_cspace.exportPicture strPath & "/" & session.sessionId & "a.gif",
"gif",
700,330
response.write "<img src=3D" &strpath & "\" &session.sessionId & "a.gif
>"
CleanUpGIF(strpath)
rs.close
set rs =3D nothing
set oconn =3D nothing
set m_cht =3D nothing
%>
</body>
</html>
----- Original Message -----
From: TomMallard <mallard@s...>
To: ASP Web HowTo <asp_web_howto@p...>
Sent: Friday, May 18, 2001 4:35 PM
Subject: [asp_web_howto] Re: Option control
> Hmmm, OK, this may help...you do need the type=3Dbutton, not
type=3Dsubmit,
the
> code you found gets what's selected but doesn't set selectedIndex
which is
> what I think you need to do.
>
> If Form1.myselect.options(i).selected =3D True Then
> Form1.myselect.selectedIndex =3D i
> ......
>
> The first line finds what's selected and the next sets the
selectedIndex
to
> i. Hopefully this is all you'll need to do since the page isn't
getting
> reloaded, it's just getting focus. If this doesn't work, you'll need
to
> store this value in a hidden field and reset selectedIndex to it using
the
> onfocus even for the body tag.
>
> tom
> ----- Original Message -----
> From: "Steve Read" <Steve.Read8787@b...>
> To: "ASP Web HowTo" <asp_web_howto@p...>
> Sent: Thursday, May 17, 2001 12:54 PM
> Subject: [asp_web_howto] Option control
>
>
> > Thank you Tom for replying
> > I think I know what you mean. I found this code on the microsoft =3D
> > website.
> > I've been trying to associate it with my code, but I'm confused
because
=3D
> > I'm
> > using the TYPE =3D3Dsubmit button, but here it uses TYPE
=3D3Dbutton. I =3D
> > tried using
> > the onsubmit method, but again it's not associating. How do I do it?
> >
> >
> >
> > <HTML>
> > <SCRIPT LANGUAGE=3D3D"VBSCRIPT">
> >
> > Sub ShowVals
> > Dim SelStr
> > For i =3D3D 0 to Form1.myselect.length - 1
> > If Form1.myselect.options(i).selected =3D3D True Then
> > selstr =3D3D selstr & Form1.myselect.options(i).value &
chr(10)
> > End If
> > Next
> > MsgBox SelStr,,"Selected Item(s)"
> > End Sub
> >
> > </SCRIPT>
> >
> > <BODY>
> >
> > <FORM NAME=3D3D"Form1">
> > <SELECT MULTIPLE NAME=3D3D"MySelect">
> > <OPTION VALUE=3D3D"10">Option 1 (10)
> > <OPTION VALUE=3D3D"20">Option 2 (20)
> > <OPTION VALUE=3D3D"30">Option 3 (30)
> > </SELECT>
> >
> > <INPUT TYPE=3D3DBUTTON onClick=3D3D"ShowVals()"
VALUE=3D3D"Show =3D
> > Value(s)">
> > </FORM>
> >
> > </BODY>
> > </HTML>
> >
> >
> > ----- Original Message -----
> > From: TomMallard <mallard@s...>
> > To: ASP Web HowTo <asp_web_howto@p...>
> > Sent: Thursday, May 17, 2001 3:44 PM
> > Subject: [asp_web_howto] Re: Combo Box problem
> >
> >
> > > Quick scan of the code but I don't see where you change
selectedindex,
=3D
> > you
> > > have a submit button so it's never changed. Think you need a
regular
> > button
> > > with an onclick function which resets the selectedindex before =3D
> > submitting.
> >
> >
>
Message #4 by "O'Hara, Elliott M" <EMOHARA@k...> on Mon, 21 May 2001 12:34:34 -0400
|
|
Hi Steve... long time no talk...
try this
when you write the options
<option value=3D"0"
<%if Request.QueryString("Chart)" =3D 0 then
response.write " selected "
end if
%>
>TURNOVER - (Sales)</option>
<option value =3D "1"
<% if request.Querystring("Chart") =3D 1 then
Response.Write " selected "
end if %>
>
blah blah blah
hope it helped
Elliott
-----Original Message-----
From: Steve Read [mailto:Steve.Read8787@b...]
Sent: Monday, May 21, 2001 11:47 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Option control
Hi Tom,
Still trying to sort this problem out. If you recall I have an option
control and my code below looks to find what index value in the option
control was chosen. I do this by :
m_nChart =3D Request.QueryString("Chart")
Now, I want the text value in the option control to display what was
chosen.
This is where it presently defaults to the the first item in the list
as I
want a particular graph displayed when the asp loads for the first
time. The
code tests for the value held in the variable called m_nChart via a
CASE
statement. It is here I feel I can control the option text value, but
it
gives me an error either variable not defined or if I remove OPTION
EXPLICIT
it returns object required. The other thing is with regard to having a
submit button or an ordinary button. I feel I got to have a submit
button
here because I'm firing an ASP and need to use the GET. An ordinary
button
would
not fire my asp. (I stand corrected)
I could still however run a procedure prior to the ASP running. I tried
Sub choice_On_Submit
Msgbox("Test")
End Sub
but it does not fire. I'm getting nowhere fast!!
Hope you can help. (or anyone else)
steve
Select Case m_nChart
Case 0
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_TO"
m_ser.Line.Color =3D RGB(255,0,0)
choice.chart.options(0).text =3D choice.chart.options(0).value
FormatChart m_cht, "TURNOVER - (Sales)", "Value", "Months", "=A3#,##"
Case 1 .........blah blah...
HERE IS THE CODE SO FAR
<%@ Language=3DVBScript %>
<% Option Explicit %>
<html>
<head>
<title>
Company Graph containing 12months data</title>
</head>
<body>
<%
Sub FormatChart(cht, sTitle, sValTitle, sCatTitle, sValNumFmt)
Dim ax 'Temp WCAxis object
Dim fnt 'Temp OWCFont object
Dim c 'Constants object
set c =3D cht.Parent.Constants
cht.HasTitle =3D True
cht.Title.Caption =3D sTitle
set fnt =3D cht.Title.Font
fnt.Name =3D "Tahoma"
fnt.Size =3D 10
fnt.Bold =3D True
For Each ax in cht.Axes
if ax.Type =3D c.chValueAxis then
ax.HasTitle =3D True
ax.Title.Caption =3D sValTitle
set fnt =3D ax.Title.Font
fnt.Name =3D "Tahoma"
fnt.Size =3D 8
fnt.Bold =3D True
ax.NumberFormat =3D sValNumFmt
else
ax.HasTitle =3D True
ax.Title.Caption =3D sCatTitle
set fnt =3D ax.Title.Font
fnt.Name =3D "Tahoma"
fnt.Size =3D 8
fnt.Bold =3D True
end if
Next
End Sub
Sub CleanUpGIF(strpath)
dim objfs
dim objfolder
dim gif
set objfs=3Dserver.createobject("scripting.filesystemobject")
set objfolder=3Dobjfs.getfolder(strpath)
for each gif in objfolder.files
if instr(gif.name, ".gif") >0 and datediff("n",gif.datelastmodified,
now)
>5 then
objfs.deletefile strpath & "\" & gif.name, true
end if
next
set objfolder =3D nothing
set objfs =3D nothing
end sub
Dim m_nChart 'Index of desired data set
Dim m_cspace 'OWC Chartspace object reference
Dim m_cht 'WCChart object reference
Dim m_ser 'WCSeries object reference
Dim c 'Constants object reference
Dim m_sFilePath 'Root file path for GIF
Dim m_ct 'Generic loop counter
Dim strConnect
Dim oconn
Dim SQL
Dim rs
Dim strpath
strpath =3D server.mapPath("/graphs")
strConnect =3D "PROVIDER=3DSQLOLEDB;" & _
"SERVER=3D(local);" & _
"DATABASE=3DPOFFLE;" & _
"UID=3Dsa;PWD=3D"
set oconn =3D server.createobject("ADODB.connection")
oconn.open strconnect
SQL=3D"SELECT * FROM Graphdata ORDER BY MONTH1 DESC"
m_nChart =3D Request.QueryString("Chart")
If IsEmpty(m_nChart) Then m_nChart =3D 0
set m_cspace =3D server.CreateObject("OWC.Chart")
set m_cht =3D m_cspace.Charts.Add()
set c =3D m_cspace.Constants
Set rs =3D Server.CreateObject("ADODB.Recordset")
rs.cursorlocation =3D 3
rs.open SQL,oconn,3
set m_cspace.datasource =3D rs
Select Case m_nChart
Case 0
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_TO"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "TURNOVER - (Sales)", "Value", "Months", "=A3#,##"
Case 1
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_TXS"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "TRANSACTIONS - (Sales)", "Value", "Months", "#,##"
Case 2
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_RFNDS_TO"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "TURNOVER - (Refunds)", "Value", "Months", "=A3#,##"
Case 3
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_RFNDS_TXS"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "TRANSACTIONS - (Refunds)", "Value", "Months",
"#,##"
Case 4
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_MSC"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "GROSS INCOME - (Merchant Service Charge)", "Value",
"Months", "=A3#,##"
Case 5
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "T_INTERCHANGE"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "INTERCHANGE", "Value", "Months", "=A3#,##"
Case 6
m_cht.Type =3D c.chChartTypeSmoothLine
Set m_ser =3D m_cht.SeriesCollection.Add()
m_ser.SetData c.chDimCategories, 0, "MONTH1"
m_ser.SetData c.chDimValues, 0, "NI"
m_ser.Line.Color =3D RGB(255,0,0)
FormatChart m_cht, "NET INCOME", "Value", "Months", "=A3#,##"
End Select
%>
<form action=3D"GetChart.asp" method=3D"GET" name=3D"choice">
Select a Report: <select name=3D"Chart">
<% if m_nChart =3D 0 then %>
<option selected value=3D"0">TURNOVER - (Sales)</option>
<option value=3D"1">TRANSACTIONS - (Sales)</option>
<option value=3D"2">TURNOVER - (Refunds)</option>
<option value=3D"3">TRANSACTIONS - (Refunds)</option>
<option value=3D"4">GROSS INCOME - (Merchant Service
Charge)</option>
<option value=3D"5">INTERCHANGE</option>
<option value=3D"6">NI</option>
<%else%>
<option value=3D"0">TURNOVER - (Sales)</option>
<option value=3D"1">TRANSACTIONS - (Sales)</option>
<option value=3D"2">TURNOVER - (Refunds)</option>
<option value=3D"3">TRANSACTIONS - (Refunds)</option>
<option value=3D"4">GROSS INCOME - (Merchant Service
Charge)</option>
<option value=3D"5">INTERCHANGE</option>
<option value=3D"6">NI</option>
<% end if %>
</select> <input type=3D"Submit" value=3D"Go" id=3D"btnSubmit"
name=3D"btnSubmit">
</form>
<hr>
<%
m_cspace.exportPicture strPath & "/" & session.sessionId & "a.gif",
"gif",
700,330
response.write "<img src=3D" &strpath & "\" &session.sessionId & "a.gif
>"
CleanUpGIF(strpath)
rs.close
set rs =3D nothing
set oconn =3D nothing
set m_cht =3D nothing
%>
</body>
</html>
Message #5 by "TomMallard" <mallard@s...> on Mon, 21 May 2001 10:23:15 -0700
|
|
This is the idea...
> <html>
>
> <head>
> <title>Company Graph containing 12months data</title>
<script>
//set action for the form so it doesn't submit from the enter key
//set selected option before submitting
function submitForm(){
document.choice.action="GetChart.asp";
document.choice.Chart.selected=document.choice.Chart.selectedIndex;
alert('Selected chart index: ' + document.choice.Chart.selected);
document.choice.submit();
}
</script>
> </head>
>
> <body>
<form method="GET" name="choice">
> Select a Report: <select name="Chart">
> <% if m_nChart = 0 then %>
>
> <option selected value="0">TURNOVER - (Sales)</option>
> <option value="1">TRANSACTIONS - (Sales)</option>
> <option value="2">TURNOVER - (Refunds)</option>
> <option value="3">TRANSACTIONS - (Refunds)</option>
> <option value="4">GROSS INCOME - (Merchant Service Charge)</option>
> <option value="5">INTERCHANGE</option>
> <option value="6">NI</option>
>
> <%else%>
>
> <option value="0">TURNOVER - (Sales)</option>
> <option value="1">TRANSACTIONS - (Sales)</option>
> <option value="2">TURNOVER - (Refunds)</option>
> <option value="3">TRANSACTIONS - (Refunds)</option>
> <option value="4">GROSS INCOME - (Merchant Service Charge)</option>
> <option value="5">INTERCHANGE</option>
> <option value="6">NI</option>
> <% end if %>
>
> </select>
<% 'change type from "submit" to "button" to be able to use the function
%>
<input type="button" value="Go" id="btnSubmit" name="btnSubmit"
onclick="submitForm();">
> </form>
The alert needs to display the selected option correctly or it isn't working
right...
tom
----- Original Message -----
From: "Steve Read" <Steve.Read8787@b...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Monday, May 21, 2001 8:47 AM
Subject: [asp_web_howto] Option control
>
> Hi Tom,
>
> Still trying to sort this problem out. If you recall I have an option
> control and my code below looks to find what index value in the option
> control was chosen. I do this by :
>
> m_nChart = Request.QueryString("Chart")
>
> Now, I want the text value in the option control to display what was
chosen.
> This is where it presently defaults to the the first item in the list as I
> want a particular graph displayed when the asp loads for the first time.
The
> code tests for the value held in the variable called m_nChart via a CASE
> statement. It is here I feel I can control the option text value, but it
> gives me an error either variable not defined or if I remove OPTION
EXPLICIT
> it returns object required. The other thing is with regard to having a
> submit button or an ordinary button. I feel I got to have a submit button
> here because I'm firing an ASP and need to use the GET. An ordinary button
would
> not fire my asp. (I stand corrected)
> I could still however run a procedure prior to the ASP running. I tried
>
> Sub choice_On_Submit
> Msgbox("Test")
> End Sub
>
> but it does not fire. I'm getting nowhere fast!!
>
>
> Hope you can help. (or anyone else)
>
> steve
>
> Select Case m_nChart
> Case 0
> m_cht.Type = c.chChartTypeSmoothLine
> Set m_ser = m_cht.SeriesCollection.Add()
> m_ser.SetData c.chDimCategories, 0, "MONTH1"
> m_ser.SetData c.chDimValues, 0, "T_TO"
> m_ser.Line.Color = RGB(255,0,0)
>
> choice.chart.options(0).text = choice.chart.options(0).value
>
> FormatChart m_cht, "TURNOVER - (Sales)", "Value", "Months", "£#,##"
>
> Case 1 .........blah blah...
>
>
>
> HERE IS THE CODE SO FAR
> <%@ Language=VBScript %>
>
> <% Option Explicit %>
>
> <html>
>
> <head>
> <title>
> Company Graph containing 12months data</title>
> </head>
>
> <body>
>
> <%
> Sub FormatChart(cht, sTitle, sValTitle, sCatTitle, sValNumFmt)
>
> Dim ax 'Temp WCAxis object
> Dim fnt 'Temp OWCFont object
> Dim c 'Constants object
>
> set c = cht.Parent.Constants
>
> cht.HasTitle = True
> cht.Title.Caption = sTitle
> set fnt = cht.Title.Font
> fnt.Name = "Tahoma"
> fnt.Size = 10
> fnt.Bold = True
>
> For Each ax in cht.Axes
> if ax.Type = c.chValueAxis then
> ax.HasTitle = True
> ax.Title.Caption = sValTitle
> set fnt = ax.Title.Font
> fnt.Name = "Tahoma"
> fnt.Size = 8
> fnt.Bold = True
> ax.NumberFormat = sValNumFmt
>
> else
> ax.HasTitle = True
> ax.Title.Caption = sCatTitle
> set fnt = ax.Title.Font
> fnt.Name = "Tahoma"
> fnt.Size = 8
> fnt.Bold = True
>
> end if
> Next
>
> End Sub
>
>
> Sub CleanUpGIF(strpath)
>
> dim objfs
> dim objfolder
> dim gif
>
> set objfs=server.createobject("scripting.filesystemobject")
> set objfolder=objfs.getfolder(strpath)
>
> for each gif in objfolder.files
> if instr(gif.name, ".gif") >0 and datediff("n",gif.datelastmodified, now)
> >5 then
>
> objfs.deletefile strpath & "\" & gif.name, true
>
> end if
> next
> set objfolder = nothing
> set objfs = nothing
>
> end sub
>
>
> Dim m_nChart 'Index of desired data set
> Dim m_cspace 'OWC Chartspace object reference
> Dim m_cht 'WCChart object reference
> Dim m_ser 'WCSeries object reference
> Dim c 'Constants object reference
> Dim m_sFilePath 'Root file path for GIF
> Dim m_ct 'Generic loop counter
>
> Dim strConnect
> Dim oconn
> Dim SQL
> Dim rs
>
> Dim strpath
>
> strpath = server.mapPath("/graphs")
>
>
> strConnect = "PROVIDER=SQLOLEDB;" & _
> "SERVER=(local);" & _
> "DATABASE=POFFLE;" & _
> "UID=sa;PWD="
>
> set oconn = server.createobject("ADODB.connection")
> oconn.open strconnect
>
> SQL="SELECT * FROM Graphdata ORDER BY MONTH1 DESC"
>
>
> m_nChart = Request.QueryString("Chart")
> If IsEmpty(m_nChart) Then m_nChart = 0
>
> set m_cspace = server.CreateObject("OWC.Chart")
> set m_cht = m_cspace.Charts.Add()
> set c = m_cspace.Constants
>
> Set rs = Server.CreateObject("ADODB.Recordset")
> rs.cursorlocation = 3
> rs.open SQL,oconn,3
>
> set m_cspace.datasource = rs
>
>
> Select Case m_nChart
> Case 0
>
> m_cht.Type = c.chChartTypeSmoothLine
>
> Set m_ser = m_cht.SeriesCollection.Add()
>
> m_ser.SetData c.chDimCategories, 0, "MONTH1"
> m_ser.SetData c.chDimValues, 0, "T_TO"
>
> m_ser.Line.Color = RGB(255,0,0)
>
> FormatChart m_cht, "TURNOVER - (Sales)", "Value", "Months", "£#,##"
>
> Case 1
> m_cht.Type = c.chChartTypeSmoothLine
>
> Set m_ser = m_cht.SeriesCollection.Add()
>
> m_ser.SetData c.chDimCategories, 0, "MONTH1"
> m_ser.SetData c.chDimValues, 0, "T_TXS"
>
> m_ser.Line.Color = RGB(255,0,0)
>
> FormatChart m_cht, "TRANSACTIONS - (Sales)", "Value", "Months", "#,##"
>
> Case 2
> m_cht.Type = c.chChartTypeSmoothLine
>
> Set m_ser = m_cht.SeriesCollection.Add()
>
> m_ser.SetData c.chDimCategories, 0, "MONTH1"
> m_ser.SetData c.chDimValues, 0, "T_RFNDS_TO"
>
> m_ser.Line.Color = RGB(255,0,0)
>
> FormatChart m_cht, "TURNOVER - (Refunds)", "Value", "Months", "£#,##"
>
>
> Case 3
> m_cht.Type = c.chChartTypeSmoothLine
>
> Set m_ser = m_cht.SeriesCollection.Add()
>
> m_ser.SetData c.chDimCategories, 0, "MONTH1"
> m_ser.SetData c.chDimValues, 0, "T_RFNDS_TXS"
>
> m_ser.Line.Color = RGB(255,0,0)
>
> FormatChart m_cht, "TRANSACTIONS - (Refunds)", "Value", "Months", "#,##"
>
> Case 4
> m_cht.Type = c.chChartTypeSmoothLine
>
> Set m_ser = m_cht.SeriesCollection.Add()
>
> m_ser.SetData c.chDimCategories, 0, "MONTH1"
> m_ser.SetData c.chDimValues, 0, "T_MSC"
>
> m_ser.Line.Color = RGB(255,0,0)
>
> FormatChart m_cht, "GROSS INCOME - (Merchant Service Charge)", "Value",
> "Months", "£#,##"
>
>
> Case 5
> m_cht.Type = c.chChartTypeSmoothLine
>
> Set m_ser = m_cht.SeriesCollection.Add()
>
> m_ser.SetData c.chDimCategories, 0, "MONTH1"
> m_ser.SetData c.chDimValues, 0, "T_INTERCHANGE"
>
> m_ser.Line.Color = RGB(255,0,0)
>
> FormatChart m_cht, "INTERCHANGE", "Value", "Months", "£#,##"
>
>
>
> Case 6
> m_cht.Type = c.chChartTypeSmoothLine
>
> Set m_ser = m_cht.SeriesCollection.Add()
>
> m_ser.SetData c.chDimCategories, 0, "MONTH1"
> m_ser.SetData c.chDimValues, 0, "NI"
>
> m_ser.Line.Color = RGB(255,0,0)
>
> FormatChart m_cht, "NET INCOME", "Value", "Months", "£#,##"
>
>
> End Select
>
>
>
> %>
>
> <form action="GetChart.asp" method="GET" name="choice">
> Select a Report: <select name="Chart">
> <% if m_nChart = 0 then %>
>
> <option selected value="0">TURNOVER - (Sales)</option>
> <option value="1">TRANSACTIONS - (Sales)</option>
> <option value="2">TURNOVER - (Refunds)</option>
> <option value="3">TRANSACTIONS - (Refunds)</option>
> <option value="4">GROSS INCOME - (Merchant Service Charge)</option>
> <option value="5">INTERCHANGE</option>
> <option value="6">NI</option>
>
> <%else%>
>
> <option value="0">TURNOVER - (Sales)</option>
> <option value="1">TRANSACTIONS - (Sales)</option>
> <option value="2">TURNOVER - (Refunds)</option>
> <option value="3">TRANSACTIONS - (Refunds)</option>
> <option value="4">GROSS INCOME - (Merchant Service Charge)</option>
> <option value="5">INTERCHANGE</option>
> <option value="6">NI</option>
> <% end if %>
>
> </select> <input type="Submit" value="Go" id="btnSubmit"
name="btnSubmit">
> </form>
> <hr>
>
> <%
> m_cspace.exportPicture strPath & "/" & session.sessionId & "a.gif", "gif",
> 700,330
> response.write "<img src=" &strpath & "\" &session.sessionId & "a.gif >"
> CleanUpGIF(strpath)
>
> rs.close
> set rs = nothing
> set oconn = nothing
> set m_cht = nothing
> %>
> </body>
> </html>
>
> ----- Original Message -----
> From: TomMallard <mallard@s...>
> To: ASP Web HowTo <asp_web_howto@p...>
> Sent: Friday, May 18, 2001 4:35 PM
> Subject: [asp_web_howto] Re: Option control
>
>
> > Hmmm, OK, this may help...you do need the type=button, not type=submit,
> the
> > code you found gets what's selected but doesn't set selectedIndex which
is
> > what I think you need to do.
> >
> > If Form1.myselect.options(i).selected = True Then
> > Form1.myselect.selectedIndex = i
> > ......
> >
> > The first line finds what's selected and the next sets the selectedIndex
> to
> > i. Hopefully this is all you'll need to do since the page isn't getting
> > reloaded, it's just getting focus. If this doesn't work, you'll need to
> > store this value in a hidden field and reset selectedIndex to it using
the
> > onfocus even for the body tag.
> >
> > tom
> > ----- Original Message -----
> > From: "Steve Read" <Steve.Read8787@b...>
> > To: "ASP Web HowTo" <asp_web_howto@p...>
> > Sent: Thursday, May 17, 2001 12:54 PM
> > Subject: [asp_web_howto] Option control
> >
> >
> > > Thank you Tom for replying
> > > I think I know what you mean. I found this code on the microsoft
> > > website.
> > > I've been trying to associate it with my code, but I'm confused
because
>
> > > I'm
> > > using the TYPE =3Dsubmit button, but here it uses TYPE =3Dbutton. I
> > > tried using
> > > the onsubmit method, but again it's not associating. How do I do it?
> > >
> > >
> > >
> > > <HTML>
> > > <SCRIPT LANGUAGE=3D"VBSCRIPT">
> > >
> > > Sub ShowVals
> > > Dim SelStr
> > > For i =3D 0 to Form1.myselect.length - 1
> > > If Form1.myselect.options(i).selected =3D True Then
> > > selstr =3D selstr & Form1.myselect.options(i).value &
chr(10)
> > > End If
> > > Next
> > > MsgBox SelStr,,"Selected Item(s)"
> > > End Sub
> > >
> > > </SCRIPT>
> > >
> > > <BODY>
> > >
> > > <FORM NAME=3D"Form1">
> > > <SELECT MULTIPLE NAME=3D"MySelect">
> > > <OPTION VALUE=3D"10">Option 1 (10)
> > > <OPTION VALUE=3D"20">Option 2 (20)
> > > <OPTION VALUE=3D"30">Option 3 (30)
> > > </SELECT>
> > >
> > > <INPUT TYPE=3DBUTTON onClick=3D"ShowVals()" VALUE=3D"Show
> > > Value(s)">
> > > </FORM>
> > >
> > > </BODY>
> > > </HTML>
> > >
> > >
> > > ----- Original Message -----
> > > From: TomMallard <mallard@s...>
> > > To: ASP Web HowTo <asp_web_howto@p...>
> > > Sent: Thursday, May 17, 2001 3:44 PM
> > > Subject: [asp_web_howto] Re: Combo Box problem
> > >
> > >
> > > > Quick scan of the code but I don't see where you change
selectedindex,
>
> > > you
> > > > have a submit button so it's never changed. Think you need a regular
> > > button
> > > > with an onclick function which resets the selectedindex before
> > > submitting.
> > >
> > >
>
|
|
 |