 |
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

December 11th, 2012, 08:28 AM
|
Registered User
|
|
Join Date: Dec 2012
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
classic asp multiple button click events
Hello all ,
Help required!!
I have 2 asp pages.
<form ACTION="Feedback_Administration_Update.asp" METHOD=POST NAME="form">
<input type="button" value="Submit" onclick="javascript:Checkit();" name="btnSubmit">
<input type="reset" value="Reset" onclick="javascript:document.location=location">
<input type="button" value="Send Response to Requester" name="btnSubmit" onclick="javascript:Checkit();"/>
</form>
in Feedback_Administration_Update.asp
I am using following code
dim buttonPressed
buttonPressed=Request.Form("btnSubmit")
select case buttonPressed
case "Submit"
Set objConn = Server.CreateObject("ADODB.Connection")
objconn.Open Application("conn")
Set objRS = Server.CreateObject("ADODB.Recordset")
Err.Clear
On Error Resume Next
strSQL = "UPDATE [Feedback] SET "
strSQL = strSQL & "Initial_Response_Date = '" & strInitial_Resp_Date & "', "
strSQL = strSQL & "Committed_Action_Date = '" & strCommitted_Action_Date & "', "
strSQL = strSQL & "Final_Outcome = '" & strFinal_Outcome & "', "
strSQL = strSQL & "Closed = '" & intClosed & "', "
strSQL = strSQL & "Closed_Date = '" & strClosed_Date & "', "
strSQL = strSQL & "RespAssignedTo = '" & strRespAssignedTo & "' "
strSQL = strSQL & " WHERE (ID = '" & strID & "')"
'response.Write(strSQL)
objRS.Open strSQL, objConn, 3, 2
'objconn.Execute strSQL
'Error Handling Part
If Err.Number <> 0 Then
Response.Buffer = True
Response.Redirect "ShowError.asp?ErrNum=" & Err.number & "&ErrSource=" & Err.source & "&ErrDesc=" & Err.description
End If
On Error GoTo 0
'End Error Handling Part
'strSQL = "SELECT * FROM Feedback WHERE (ID = " & strID & ")"
objconn.Close
set objRS = nothing
Set objConn = nothing
Response.Redirect "feedback_administration.asp?ID=" & regEx.Replace((request.form("ID")), "''") & "&lstPages=" & Trim(Request("lstPages")) & "&view=" & Request("view")& "&strSuccess1=" &"Success"
case "Send Response to Requester"
Dim ObjSendMail
Dim strMailTo
Dim HTML
Set ObjSendMail = CreateObject("CDO.Message")
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mailgate.qintra.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
ObjSendMail.Configuration.Fields.Update
ObjSendMail.To = "sonali.malla@centurylink.com"
ObjSendMail.Subject = "Response to your Business Improvement Feedback"
ObjSendMail.From = "CIA Feedback<cia.feedback.notification@centurylink.com >"
ObjSendMail.HTMLBody = "<p>Test mail</p>"
ObjSendMail.Send
End Select
I am not sure why they are not working on clicking any button.
when I click on submit the page ,it should update the code
when I click on submit Send Response to Requester,it should send email. Please help me.
|

December 11th, 2012, 09:09 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Where is the function Checkit defined? Can you post its code?
Imar
|

December 11th, 2012, 09:45 AM
|
Registered User
|
|
Join Date: Dec 2012
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
classic asp multiple button click events
Hi Imar,
I am calling javascript function checkit() in feedback_Administration.asp page.
function Checkit() {
var entry_date = document.form.txtentryDt.value;
var closed_date = document.form.txtclsedDt.value;
var eDate = new Date(entry_date);
var cDate = new Date(closed_date);
var compDate = cDate - eDate;
if (compDate < 0) {
alert("Closed date should be greater than Feedback entry date");
return
}
document.form.submit();
}
|

December 11th, 2012, 01:46 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Your JavaScript code is referring to form controls (such as txtentryDt) that don't exist in the code; this causes the code to crash and then the form doesn't get submitted.
Hope this helps,
Imar
|

December 12th, 2012, 01:04 AM
|
Registered User
|
|
Join Date: Dec 2012
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
classic asp multiple button click events
I am sorry,I should have written total code here,I thought it would be very big to put the code here,so I have not put the html part of my code.
Here is my Feedback_Administration_Update.asp page
<form ACTION="Feedback_Administration_Update.asp" METHOD=POST NAME="form">
<!-- #include file="header.asp" -->
<!-- #include file="menu.asp" -->
<div class="wdcontainer bodycntn">
<div class="floatr">
<ul>
<li class="logout"><a href="Logout.asp">Logout</a></li>
</ul>
</div>
<!--Text Container Start-->
<h1>CIA Feedback Administation</h1>
<INPUT TYPE=HIDDEN NAME=ID VALUE='<%=request("ID")%>'>
<INPUT TYPE=HIDDEN NAME=lstPages VALUE='<%=Trim(Request("lstPages"))%>'>
<INPUT TYPE=HIDDEN NAME=view VALUE='<%=Request("view")%>'>
<label>Name</label><input name="input4" type="text" value="<%=objRSFeedback.fields("Name").value%>">
<span class="spacer"> </span>
<label>Email</label><input name="txtEmail" type="text" value="<%=objRSFeedback.fields("Email").value%>">
<div class="clear"></div>
<label>Feedback Entry Date</label><input id="txtentryDt" name="Fb_entry_Date" type="text" class="date" value="<%=FormatDateTime(objRSFeedback.fields("Ent ry_Date").value,2)%>">
<span class="spacer"> </span>
<label>Workgroup</label><input name="input6" type="text" value="<%=objRSFeedback.fields("Workgroup").value% >">
<div class="clear"></div>
<label>Feedback(Unedited)</label><textarea rows="5" class="double"><%=objRSFeedback.fields("Feedback") .value%></textarea>
<div class="clear"></div>
<label>Committed Action Date</label><input id="txtCmttedActDt" name="Committed_Action_Date" type="text" class="date" value="<%=objRSFeedback.fields("Committed_Action_D ate").value%>">
<span class="spacer"> </span>
<label>Initial Response Date</label><input id="txtInitialRespDt" name="Initial_Resp_Date" type="text" class="date" value="<%=objRSFeedback.fields("Initial_Response_D ate").value%>">
<div class="clear"></div>
<label>Final Outcome</label><textarea name="Final_Outcome" rows="5" class="double"><%=objRSFeedback.fields("Final_Outc ome").value%></textarea>
<div class="clear"></div>
<label>Closed</label>
<select name="Closed" id="ClosedFeedback">
<%If objRSFeedback.fields("Closed").value = 1 Then%>
<option value="Yes" selected="selected">Yes</option>
<option value="No">No</option>
<%else%>
<option value="No" selected="selected">No</option>
<option value="Yes">Yes</option>
<%End If%>
</select>
<span class="spacer"> </span>
<label>Closed Date</label><input id="txtclsedDt" name="Closed_Date" type="text" class="date" value="<%=objRSFeedback.fields("Closed_Date").valu e%>">
<div class="clear"></div>
<label>Response Assigned To</label><input name="RespAssignedTo" type="text" value="<%=objRSFeedback.fields("RespAssignedTo").v alue%>">
<div class="clear"></div>
<label></label>
<input type="button" value="Submit" onclick="javascript:Checkit();" name="btnSubmit">
<input type="reset" value="Reset" onclick="javascript:document.location=location">
<input type="button" value="Send Response to Requester" name="btnSubmit" onclick="javascript:Checkit();"/>
<div class="clear"></div>
<% if Request.QueryString("strSuccess1") <> "" AND Request.QueryString("strSuccess1") = "Success" Then %>
<div class="successmsg">Feedback Updated.</div>
<%end if %>
<!--Text Container End-->
</div>
<div class="clearftr"></div>
</form>
|

December 12th, 2012, 04:12 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Still hard to day as this is the server side code including ASP code and includes that may affect the final behavior in the browser.
Try debugging your JavaScript code. Use a tool like Firebug (for Firefox) or add the word debugger to the Checkit method and then see how it behaves.
Although not optimal, the code you initially posted posted should work provided that the controls indeed exist.
Once you verified the page actually posts back to the server, you can begin to diagnose why it doesn't work there (if it doesn't).
Cheers,
Imar
|

December 12th, 2012, 04:39 AM
|
Registered User
|
|
Join Date: Dec 2012
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
classic asp multiple button click events
Thanks Imar for looking into it,
I have got the solution to this,
The button type should be of submit,I did input button type as "button",so it was not getting in the form post asp page.Now its working.
I was eariler working on asp.net,now I have been given classic asp project to work on,Can you tell me how can I debug the asp code ?Other than response.write.Its becoming hard for me to check where the error is.
Regards,
Sonali Malla
|

December 12th, 2012, 05:20 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
The button type should be of submit,I did input button type as "button",so it was not getting in the form post asp page.
|
That's odd. The JavaScript function you called submits the form as well through code so it should have worked.
Search Google for "debug classic asp in visual studio" to learn how to use Visual Studio to debug classic ASP.
Cheers,
Imar
|
|
 |