aco000636
asked on
Cassic ASP call vbScript on_click of button
Hi All
Any help gratefully received.
Very little ASP experience and m trying to make minor change to existing ASP page but cant work out how to get the value of a text box and pass it to a vbScript.
I have a page with a dropdown, a user should select a vaue, press a button, a vaule of a text box needs to be passed to a vbScript.
See following code
Any help gratefully received.
Very little ASP experience and m trying to make minor change to existing ASP page but cant work out how to get the value of a text box and pass it to a vbScript.
I have a page with a dropdown, a user should select a vaue, press a button, a vaule of a text box needs to be passed to a vbScript.
See following code
<html>
<head>
<title>ACO Test</title>
<script language="VBSript">
<!--
Sub Button_OnClick
Dim frmPeriod
Set frmPeriod = document.forms["Period"]
MsgBox "Value is " & frmPeriod.text3.value
response.write "the value is: " & frmPeriod.text3.value
Response.Write Request.Querystring("text3")
End Sub
-->
</script>
<script type="text/Javascript">
function GetValue(ax){
//alert(ax);
var mysel =document.forms['Period'].elements['PeriodDD'];
var seltxt = mysel.options[mysel.selectedIndex].text;
document.forms["Period"].text1.value=ax;
document.forms["Period"].text3.value=seltxt;
}
</script>
<style>
@import url(integration.css);
</style>
<form name="Period">
<select name="PeriodDD" id="PeriodDD" onchange='GetValue(document.forms["Period"].PeriodDD.value)';>
<Option value=1> Jan 2011</Option>
<Option value=2 selected>Feb 2011</Option>
</select>
<%Response.Write Request.Querystring("document.forms(0).text3.value")%>
<br /><br />
<p>Result is: <input type="text" id="text1" name="text1"></p>
<p>Value is: <input type="text" id="text3" name="text3"></p>
<p>New button: <input type="button" id="btn1" Value="Button"</p>
</form>
</head>
</body>
</html>
plz check this out..
it works..
I hope this will solve ur problem..
it works..
I hope this will solve ur problem..
<html>
<head>
<title>ACO Test</title>
<script type="text/Javascript">
function getvalue(){
var combo = document.getElementById("period");
var itembox = document.getElementById("text1");
var ibox = document.getElementById("text3");
itembox.value = combo.options[combo.selectedIndex].text
ibox.value = combo.options[combo.selectedIndex].text
}
</script>
<style>
@import url(integration.css);
</style>
<form name="form1">
<select name="PeriodDD" id="period">
<Option value=1> Jan 2011</Option>
<Option value=2 selected>Feb 2011</Option>
</select>
<input type="button" id="btn1" Value="Button" onclick="getvalue()">
<p>Result is: <input type="text" id="text1" name="text1"></p>
<p>Value is: <input type="text" id="text3" name="text3"></p>
</form>
</head>
</body>
</html>
change the line number 13 from
ibox.value = combo.options[combo.select edIndex].t ext
to
ibox.value = combo.options[combo.select edIndex].v alue
you will get the list box value..
ibox.value = combo.options[combo.select
to
ibox.value = combo.options[combo.select
you will get the list box value..
ASKER
Lucky20 - Appreciate appreciate your comment/help.
I dont have an issue running the code to get the values back from the select. Its passing the values to a vbScript when I click the button. Not sure if you have IIS on your machine but if you paste my code in to a asp page you'll see what I mean.
As you can see I tried various methods without sucess. Mainly because I dont really understand how to catch input.
Thanks
I dont have an issue running the code to get the values back from the select. Its passing the values to a vbScript when I click the button. Not sure if you have IIS on your machine but if you paste my code in to a asp page you'll see what I mean.
As you can see I tried various methods without sucess. Mainly because I dont really understand how to catch input.
Thanks
ASKER
Lucky20 - apologies missed the last post. looking at your comment now :-)
I copied ur code in asp page and made chages to it..
yes i have iis on my machine..
yes i have iis on my machine..
ASKER
Hi there
I can see that your code does fill the combo. However, unfortunately I'm still lost.
I want a user to open the page
select a value in the combo
press a button that will pass the currently selected item to my vbScript
sort of
as you saw the orginal code did fill the text boxs. Now I had the values, I wanted to pass them on to another script [vbScript]
<input type="button" id="btn1" Value="Button1" onclick="Run_vbScript_Func tion(combo .value)">
Appreciate you taliking time to contribute.
I can see that your code does fill the combo. However, unfortunately I'm still lost.
I want a user to open the page
select a value in the combo
press a button that will pass the currently selected item to my vbScript
sort of
as you saw the orginal code did fill the text boxs. Now I had the values, I wanted to pass them on to another script [vbScript]
<input type="button" id="btn1" Value="Button1" onclick="Run_vbScript_Func
Appreciate you taliking time to contribute.
after selecting combo,the values are passing to textboxes.. these text box values you want to send it to vbscript right?correct me if I am wrong..
ASKER
Hi, yes thats correct.
The text boxes will be used for returning a message to the user, processing report for period...
and the numeric value used to pass to a stored proc which fills the rest of the page with a report.
So on click, read vaules of text boxes, pass values to vbScript, write a comment for confirmation, call stored proc, fill the page.
regards ACO
The text boxes will be used for returning a message to the user, processing report for period...
and the numeric value used to pass to a stored proc which fills the rest of the page with a report.
So on click, read vaules of text boxes, pass values to vbScript, write a comment for confirmation, call stored proc, fill the page.
regards ACO
I will try to do this now... let see any one can help you mean while..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi there
thanks for your code, that seems to have worked. FF is a problem but I can get round that. Really appreciate your help with this.
Regards ACO
thanks for your code, that seems to have worked. FF is a problem but I can get round that. Really appreciate your help with this.
Regards ACO
ASKER
Hi All
In the end I put the problem out to tender and paid someone to fix it for me. However, the results were pretty simple in the end, running the SQL was placed within the <form> section and everything works fine.
Thanks for everyones input.
Regards ACO
In the end I put the problem out to tender and paid someone to fix it for me. However, the results were pretty simple in the end, running the SQL was placed within the <form> section and everything works fine.
Thanks for everyones input.
Regards ACO
</head>
<body>
<form action="salesreport.asp" method="post">
<%="Logged in as: " & tUser %>
<%
if not bAuth THen
%>
NOT AUTHORISED
<%
Else
Dim i, iCurMonth, strPeriod
Dim receivedMonth
if Request.Form("Period") = "" then
receivedMonth = Month(Date)
else
receivedMonth = CInt(Request.Form("Period"))
end if
iCurMonth = Month(Date)
'the following on click, I would like it to refresh the query
%>
<%= "!" & receivedMonth & "!" %>
<input type="submit" value=" - Run - "/>
<select name="Period" id="Period">
<%
If CInt(iCurMonth) > 1 Then
For i = CInt(iCurMonth) + 1 To 12
%>
<Option value="<%=i%>" <% if receivedMonth=i then Response.write("selected") end if %>><%=MonthName(i) & " - " & CStr(Year(Date) - 1)%></Option>
<%
Next
For i = 1 To CInt(iCurMonth)
%>
<Option value="<%=i%>" <% if receivedMonth=i then Response.write("selected") end if %>><%=MonthName(i) & " - " & CStr(Year(Date))%></Option>
<%
Next
Else
For i = 1 to 11
%>
<Option value="<%=i%>" <% if receivedMonth=i then Response.write("selected") end if %>><%=MonthName(i) & " - " & CStr(Year(Date))%></Option>
<%
Next
%>
<Option value="<%=i%>" <% if receivedMonth=i then Response.write("selected") end if %>><%=MonthName(i) & " - " & CStr(Year(Date))%></Option>
<%
End If
Dim cn, rc, strConn
'ACO UPDATE
strConn = "myConnection;"
Set cn = CreateObject("ADODB.Connection")
Set rc = CreateObject("ADODB.Recordset")
'recordset.Open Source, ActiveConnection, CursorType, LockType, Options
'---- CursorType Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3
'---- LockTypeEnum Values ----
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4
'---- CursorLocationEnum Values ----
Const adUseServer = 2
Const adUseClient = 3
dim sqlCustomReport, sqlCountCalls, sqlEngNotActiveToday
'---if bAuth then
sqlCustomReport = "EXECUTE PROCEDURE spSalesAnalysis_v2(" & CStr(receivedMonth) & ");"
%>
<table>
<thead>
<th>Title</th>
<th>Month</th>
<th>Value</th>
<th>Currency</th>
</thead>
<%
cn.Open strConn
rc.CursorLocation = adUseClient
rc.CursorType = adOpenStatic
rc.LockType = adLockReadOnly
'ON button click, run this report
Set rc = cn.Execute( sqlCustomReport )
IF rc.EOF = True Then
response.write "<tr><td colspan='4'>No data returned...</td></tr>"
Else
rc.MoveFirst
do while not rc.EOF
%>
<tr>
<td><%=trim(rc.Fields(0))%></td>
<td><%=trim(rc.Fields(1))%></td>
<td style="text-align:right;"><%=FormatNumber(trim(rc.Fields(2)), 2, -1, 0, -1) %></td>
<td style="text-align:center;"><%=trim(rc.Fields(3))%></td>
</tr>
<%
rc.MoveNext
Loop
If rc.State <> 0 Then rc.close
If cn.State <> 0 Then cn.Close
end if
end if
%>
</form>
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
I posted the same question previously..
this is the result i got..
I am just posting my code here to check,it may help you
to get the values into text box from selection ,you need to use ajax.
Open in new window
please find the ajax code line from 32 to 54