`I've been searching a lot, and I think the answer to my task is a call to an AJAX function. I'm using classic ASP. Please have in mind that I'm a total newbie. I really need someone to take my hand and tell me what to do. The examples I've found so far doesn't keep the same position on the website on submit. The idea is to press the toggle button (on/off) and save immidiately. That part is working perfectly. But when you have a lot of toggle buttons, and the submit gets you to the top of the page, you have a lot of scrolling down to do after every submit
The folowing is working just fine; either it's on or off. No need to do anything, but to press the toggle button. But if you are way down the webpage, you go way up to the top of the page, and you need to scroll way down to continue where you left off. This is where I want the page to be steady as a rock: Don't do anything on submit. Don't move up, don't move down. Stay put. I hope someone can help.
<%
If Request("mode") = "msgfromadmin" Then
Dim dato10, vUser10
dato10 = Day(Date) & "/" & Month(Date) & "/" & Year(Date) & " " & Time()
vUser10 = SQLEncode(Session("username"))
If Request.Form("msgfromadmin") = Lcase("on") Then
msgfromadmin = 1
Else
msgfromadmin = 0
End If
SQL = Conn.Execute("UPDATE usersettings SET msgfromadmin = " & msgfromadmin & " WHERE username = '" & SQLEncode(Session("username")) & "'")
Response.Redirect("/profile/mysettings/")
End If
%>
<head>
<style>
.switch{position:relative;display:inline-block;width:3.43em;height:1.75em;}
.switch input{opacity:0;width:0;height:0;}
.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;-webkit-transition:.4s;transition:.4s;}
.slider:before{position:absolute;content:"";height:1.26em;width:1.26em;left:0.25em;bottom:0.25em;background-color:white;-webkit-transition: .4s;transition:.4s;}
input:checked + .slider{background-color:#4d72ff;}input:focus + .slider{box-shadow: 0 0 0.063em #c4cbe7;}
input:checked + .slider:before{-webkit-transform:translateX(1.625em);-ms-transform:translateX(1.625em);transform:translateX(1.625em);}
.slider.round{border-radius:2.125em;}.slider
.round:before{border-radius:50%;}
</style>
</head>
<html>
<body>
<form name="msgfromadmin" action="/profile/mysettings/" method="post">
<input type="hidden" name="mode" value="msgfromadmin">
<div class="col-12 form-group row mt-4">
<div class="col-1 form-group text-center">
<label class="switch">
<input type="checkbox" name="msgfromadmin" onChange="this.form.submit();"<% If RSchosenSetting("msgfromadmin") = 1 Then %> checked<% End If %>>
<span class="slider"></span>
</label>
</div>
<div class="col-11 form-group">
Send a mail when there's a message from admin
</div>
</div>
</form>
</body>
</html>
Is it something like this you want??
You will have to obviously do the database connections etc on the submitpage.asp
I added the loop to the text and slider to generate a page that is longer.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>msgfromadmin</title>
</head>
<style>
.switch{position:relative;display:inline-block;width:3.43em;height:1.75em;}
.switch input{opacity:0;width:0;height:0;}
.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;-webkit-transition:.4s;transition:.4s;}
.slider:before{position:absolute;content:"";height:1.26em;width:1.26em;left:0.25em;bottom:0.25em;background-color:white;-webkit-transition: .4s;transition:.4s;}
input:checked + .slider{background-color:#4d72ff;}input:focus + .slider{box-shadow: 0 0 0.063em #c4cbe7;}
input:checked + .slider:before{-webkit-transform:translateX(1.625em);-ms-transform:translateX(1.625em);transform:translateX(1.625em);}
.slider.round{border-radius:2.125em;}.slider
.round:before{border-radius:50%;}
</style>
</head>
<html>
<body>
<form name="msgfromadmin" action="msgfromadmin.asp" method="post">
<input type="hidden" name="mode" value="msgfromadmin">
<div class="col-12 form-group row mt-4">
<%for i = 1 to 100 %>
<div class="col-1 form-group text-center">
<label class="switch">
<input type="checkbox" name="msgfromadmin<%= i %>" id="msgfromadmin<%= i %>" onChange="loadXMLDoc('<%= i%>','message <%= i%> from admin')" <% If request("msgfromadmin" & i) = "on" Then %> checked<% End If %>>
<span class="slider"></span>
</label>
</div>
<div class="col-11 form-group" id=adminmessage<%=i%>>
Send a mail when there's a message from admin
</div>
<% next %>
</div>
</form>
<script>
function loadXMLDoc(incoming, incoming2) {
var demoChecked = document.getElementById("msgfromadmin"+ incoming).checked;
if (demoChecked == true) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("adminmessage"+incoming).innerHTML = this.responseText;
}
};
xhttp.open("post", "SubmitPage.asp?msgfromadmin="+ incoming +"&message="+incoming2, true);
xhttp.send();
document.getElementById("adminmessage"+incoming).innerHTML = "Mail sent to admin";
} else {
document.getElementById("adminmessage"+incoming).innerHTML = "Send a mail when there's a message from admin";
}
}
</script>
</body>
</html>
and the SubmitPage.asp
<%
If Request("msgfromadmin") <> "" then
Dim dato10, vUser10
dato10 = Day(Date) & "/" & Month(Date) & "/" & Year(Date) & " " & Time()
response.write "Mail sent to admin at " & dato10
' vUser10 = SQLEncode(Session("username"))
' SQL = Conn.Execute("UPDATE usersettings SET msgfromadmin = " & msgfromadmin & " WHERE username = '" & SQLEncode(Session("username")) & "'")
End If
%>
I have created a repeater as the page type, with a transformation for which I need to "show" the fields if the user clicks "Read More" and then hide if the user clicks "Read Less". I know how to do this in html/js, but not quite sure in a transformation. I am new to writing them, but need to do it this way so that other team members can add stories via a form format. Here is what I have written so far. Each area that is in parenthesis is a field in the page type. Can someone look at my code first to see if I wrote it correctly, and also tell me how to create the show/hide as part of it.
<li>
<div class="Alumi-stories <%# Eval<string>("CssClass") %>">
<%# String.IsNullOrEmpty(Eval<string>("Image1")) ? "" : "<img class=\"Image\" alt=\"" + Eval("ImageAlt") + "\" src=\"" + Eval("Image") + "\" />" %>
<%# String.IsNullOrEmpty(Eval<string>("Name")) ? "" : "<span class=\"Name\">" + Eval("Name") + "</span>" %>
<hr class="grn200">
<%# String.IsNullOrEmpty(Eval<string>("Quote"")) ? "" : "<div class=\"Quote\">" + Eval("Quote") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Attended"")) ? "" : "<div class=\"Attended\">" + Eval("Attended") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Studied"")) ? "" : "<div class=\"Studied\">" + Eval("Studied") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Introduction")) ? "" : "<div class=\"Introduction\">" + Eval("Introduction") + "</div>" %>
<div class="alumiText <%# Eval<string>("CssClass") %>" onclick="read-more-show(this);">
<p><a class="read-more-show hide" href="#">Read More</a> <span class="read-more-content"></p>
<%# String.IsNullOrEmpty(Eval<string>("Question1")) ? "" : "<div class=\"Question1\">" + Eval("Question1") + "</div>" %>
<hr class="grn100">
<%# String.IsNullOrEmpty(Eval<string>("Answer1")) ? "" : "<div class=\"Answer1\">" + Eval("Answer1") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Question2")) ? "" : "<div class=\"Question2\">" + Eval("Question2") + "</div>" %>
<hr class="grn100">
<%# String.IsNullOrEmpty(Eval<string>("Answer2")) ? "" : "<div class=\"Answer2\">" + Eval("Answer2") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Question3")) ? "" : "<div class=\"Question3\">" + Eval("Question3") + "</div>" %>
<hr class="grn100">
<%# String.IsNullOrEmpty(Eval<string>("Answer3")) ? "" : "<div class=\"Answer3\">" + Eval("Answer3") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Question4")) ? "" : "<div class=\"Question4\">" + Eval("Question4") + "</div>" %>
<hr class="grn100">
<%# String.IsNullOrEmpty(Eval<string>("Answer4")) ? "" : "<div class=\"Answer4\">" + Eval("Answer4") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Question5")) ? "" : "<div class=\"Question5\">" + Eval("Question5") + "</div>" %>
<hr class="grn100">
<%# String.IsNullOrEmpty(Eval<string>("Answer5")) ? "" : "<div class=\"Answer5\">" + Eval("Answer5") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Question6")) ? "" : "<div class=\"Question6\">" + Eval("Question6") + "</div>" %>
<hr class="grn100">
<%# String.IsNullOrEmpty(Eval<string>("Answer6")) ? "" : "<div class=\"Answer6\">" + Eval("Answer6") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Question7")) ? "" : "<div class=\"Question7\">" + Eval("Question7") + "</div>" %>
<hr class="grn100">
<%# String.IsNullOrEmpty(Eval<string>("Answer7")) ? "" : "<div class=\"Answer7\">" + Eval("Answer7") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Question8")) ? "" : "<div class=\"Question8\">" + Eval("Question8") + "</div>" %>
<hr class="grn100">
<%# String.IsNullOrEmpty(Eval<string>("Answer8")) ? "" : "<div class=\"Answer8\">" + Eval("Answer8") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Question9")) ? "" : "<div class=\"Question9\">" + Eval("Question9") + "</div>" %>
<hr class="grn100">
<%# String.IsNullOrEmpty(Eval<string>("Answer9")) ? "" : "<div class=\"Answer9\">" + Eval("Answer9") + "</div>" %>
<%# String.IsNullOrEmpty(Eval<string>("Question10")) ? "" : "<div class=\"Question10\">" + Eval("Question10") + "</div>" %>
<hr class="grn100">
<%# String.IsNullOrEmpty(Eval<string>("Answer10")) ? "" : "<div class=\"Answer10\">" + Eval("Answer10") + "</div>" %>
<p><a class="read-more-hide hide" href="#">Read Less</a></span></p>
</div>
</div>
</li>
2 issues I see:
Using this example, you'll want to make sure when you process the Eval("Name") value, it's done as a string since that's what you're concatenating with.
<%# String.IsNullOrEmpty(Eval<string>("Name")) ? "" : "<span class=\"Name\">" + Eval("Name") + "</span>" %>
It should look like this:
<%# String.IsNullOrEmpty(Eval<string>("Name")) ? "" : "<span class=\"Name\">" + Eval<string>("Name") + "</span>" %>
The second issue is you're missing a closing parenthesis after the </span> tag.
Last item is you could simplify this a bit with an out of the box transformation method. It could look like this:
<%# IfEmpty(Eval("Name"), "", "<span class='Name'>" + Eval<string>("Name") + "</span>") %>
I have an entity (asset) that has an N:1 relationship with Parent Account and Organisation (both the same Account entities)
In the account entity, I can see either assets linked to it via parent account, or assets linked to it via organisation account, but not both (as far as I can work out).
I can't change the schema to have parent accounts as one entity and organisation accounts as another entity.
Is it possible to show both relationships in one sub-grid, or am I purely limited to having two separate sub-grids on the account entity?
You cannot do this out-of-the-box since a sub-grid only supports a single 1:N relationship. You could do this by creating custom FetchXml and modifying the sub-grid via JavaScript since the query is possibly via FetchXml and can be built in Advanced Find.
Follow this blog article for information on setting the FetchXML of a sub-grid.
You'll need an on load function on your form similar to this:
function filterSubGrid() {
var accountsGrid = document.getElementById("accounts"); //grid to filter
if (accountsGrid == null) { //make sure the grid has loaded
setTimeout(function () {
filterSubGrid();
}, 2000); //if the grid hasn’t loaded run this again when it has
return;
}
var contactValue = Xrm.Page.getAttribute("primarycontactid").getValue(); //field to filter by
var contactId = "00000000-0000-0000-0000-000000000000"; //if filter field is null display nothing
if (contactValue != null) {
var contactId = contactValue[0].id;
}
//fetch xml code which will retrieve all the accounts related to the contact
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='account'>" +
" <attribute name='name' />" +
" <attribute name='address1_city' />" +
" <attribute name='primarycontactid' />" +
" <attribute name='telephone1' />" +
" <attribute name='accountid' />" +
" <order attribute='name' descending='false' />" +
" <filter type='and'>" +
" <condition attribute='primarycontactid' operator='eq' uitype='contact' value='" + contactId + "' />" +
" </filter>" +
" <link-entity name='contact' from='contactid' to='primarycontactid' visible='false' link-type='outer' alias='accountprimarycontactidcontactcontactid'>" +
" <attribute name='emailaddress1' />" +
" </link-entity>" +
" </entity>" +
"</fetch>";
accountsGrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid
accountsGrid.control.refresh(); //refresh the sub grid using the new fetch xml
}
Except you'll need FetchXML similar to this:
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='new_asset'>" +
" <attribute name='new_assetid' />" +
" <attribute name='new_name' />" +
" <attribute name='createdon' />" +
" <order attribute='new_name' descending='false' />" +
" <filter type='or'>" +
" <condition attribute='new_organizationaccount' operator='eq' value='" + accountId + "' />" +
" <condition attribute='new_parentaccount' operator='eq'value='" + accountId + "' />" +
" </filter>" +
" </entity>" +
"</fetch>";
The Advanced Find to get the FetchXML query is:
I have 10 images that are displayed as a slideshow using the Jquery Cycle plugin.
At a time 4 images are displayed . When the user clicks the next button the next 4 images are displayed.
Under each image there is a dropdown. When I select an item in the dropdown I want to change the image to some other image depending on the item the user has selected in the dropdowm.
I also need to change the 'href' of the image when the user selects another item in the dropdown.
When the user selects an item in the dropdown I using the javascript code given below to change the image and other details
Javascript Code
document.getElementById('prodLink' + productId).href = "productDetails.aspx?id=" + productAttributeValueId;
document.getElementById('prodImageLink' + productId).href = "productDetails.aspx?id=" + productAttributeValueId;
document.getElementById('prodImage' + productId).src = "ProductImages/" + productImage;
document.getElementById('prodImage' + productId).className=document.getElementById('prodImage' + productId).className;
document.getElementById('prodNameLink' + productId).href = "productDetails.aspx?id=" + productAttributeValueId;
document.getElementById('productPrice' + productId).innerHTML = productPrice;
document.getElementById('prodAttribute' + productId).innerHTML = attributeValue;
The HTML Code
<div class="cycle-slideshow" data-cycle-fx="scrollHorz" data-cycle-timeout="0"
data-cycle-slides="> ul" data-cycle-prev="div.pagers a.latest_prev" data-cycle-next=
"div.pagers a.latest_nxt">
<ul class="product_show">
<li class="column">
<div class="img">
<div class="hover_over">
<a class="link" href="#">link</a> <a class="cart" href="#">cart</a>
</div><a href="#"><img src="images/photos/4c_pic8.jpg" width="218" height="207"
alt="" /></a>
</div><a href="#" style="line-height:14px;">Product 1,<br />
1 Kg Pouch<br /></a> <span class="ourPrice">Our Price: $121.20</span><span class=
"saveText"><br /></span>
<div class="dropdowndiv">
<select name="search_category1" class="default" tabindex="1" style=
"color: #333333;">
<option value="">
Pack size
</option>
<option value="amazed">
Amazed
</option>
</select>
</div><br />
<br />
<label for="textfield">Qty</label> <input type="text" name="textfield" id=
"textfield" class="carttextbox" /> <img src="images/img/but_addtocart.png"
alt="" width="72" height="16" align="absmiddle" /><br />
<br />
</li>
</ul>
Here is the modified working javascript code that changes the image(and some other information) in a Jquery Cycle2 slideshow
I added $('.cycle-slideshow').cycle('destroy'); before changing any information
After that I change all the required information
Then I call $('.cycle-slideshow').cycle(); to recreate the slideshow
$('.cycle-slideshow').cycle('destroy');
document.getElementById('prodLink' + productId).href = "productDetails.aspx?id=" + productAttributeValueId;
document.getElementById('prodImageLink' + productId).href = "productDetails.aspx?id=" + productAttributeValueId;
document.getElementById('prodImage' + productId).src = "ProductImages/" + productImage;
document.getElementById('prodImage' + productId).className=document.getElementById('prodImage' + productId).className;
document.getElementById('prodNameLink' + productId).href = "productDetails.aspx?id=" + productAttributeValueId;
document.getElementById('productPrice' + productId).innerHTML = productPrice;
document.getElementById('prodAttribute' + productId).innerHTML = attributeValue;
$('.cycle-slideshow').cycle();
I am not able to retrieve records from Oracle based on multiple inputs.
Here is my code:
Search.asp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SearchMDFnode</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#99CCFF">
<p align="center"><font color="#9966CC" size="5" face="Georgia, Times New Roman, Times, serif"><strong>Records</strong></font></p>
<style>
A:link {text-decoration: none;color: blue;}
A:visited {text-decoration: none;}
A:hover {text-decoration:underline; color: red;}
</style>
<script>
function updateDate(fname){
var instDate = showModalDialog('upd_date.html','Select Date','dialogHeight:375px;dialogWidth:287px;status:no;resizable:no;help:no;');
if (instDate == -1 || instDate == null){
alert("You did not select any date.")
fname.focus()
} else {
fname.value = instDate
}
}
function findNull(frm,tname,optnull,optorder){
var nfname = optnull.value
var ofname = optorder.value
frm.action = "MDFnodeDisplayTable.asp?opt=" + tname + "&nfield=" + nfname + "&order=" + ofname
frm.submit()
}
</script>
<form name="SearchMDFnode" action="Display.asp?opt=MDFnode" method="post">
<table width="68%" border="1" align="center" cellpadding="3" cellspacing="2">
<table width="94%" border="1" align="center" cellpadding="3" cellspacing="2">
<tr>
<td width="19%">CCP_CODE</td>
<td width="22%"><strong>
<select name="CCP_CODE" id="select4" title="BLOCK_HOUSE">
<option></option>
<option>AM</option>
<option>AR</option>
<option>BD</option>
<option>BP</option>
<option>CG</option>
<option>CT</option>
<option>CY</option>
<option>ES</option>
<option>GL</option>
<option>HG</option>
<option>JE</option>
<option>JR</option>
<option>JW</option>
<option>KT</option>
<option>NT</option>
<option>OC</option>
<option>PL</option>
<option>QT</option>
<option>TB</option>
<option>TP</option>
<option>TS</option>
</select>
</strong></td>
<td width="19%">NODE_SITE_ID</td>
<td width="40%"><strong>
<input name="NODE_SITE_ID" type="text" id="NODE_SITE_ID" size="10" maxlength="10" title="NODE_SITE_ID(max 7 digits)">
</strong></td>
</tr>
<tr>
<td>STREET_NAME</td>
<td><strong>
<input name="STREET_NAME" type="text" id="STREET_NAME" size="30" maxlength="30" title="STREET_NAME(max 30 digits)">
</strong></td>
<td>BUILDING_NAME</td>
<td><strong>
<input name="BUILDING_NAME" type="text" id="BUILDING_NAME" size="25" maxlength="25" title="BUILDING_NAME(max 7 digits)">
</strong></td>
</tr>
<tr>
<td height="38">BLOCK_HOUSE</td>
<td><strong>
<select name="BLOCK_HOUSE" id="select3" title="BLOCK_HOUSE">
<option></option>
<option>BLOCK</option>
<option>HOUSE</option>
</select>
</strong></td>
<td>BLOCK_DESC_NO</td>
<td><strong>
<input name="BLOCK_DESC_NO" type="text" id="BLOCK_DESC_NO" size="6" maxlength="6" title="BLOCK_DESC_NO(max 6 digits)">
</strong></td>
</tr>
<tr>
<td>REMARK</td>
<td><strong>
<input name="REMARK" type="text" id="REMARK" size="50" maxlength="50" title="REMARK(max 50 char)">
</strong></td>
<td>EQ_RM</td>
<td><strong>
<input name="EQ_RM" type="text" id="EQ_RM" size="3" maxlength="3" title="EQ_RM(max 6 digits)">
</strong></td>
</tr>
<tr>
<td>TYPE</td>
<td><strong>
<select name="EQ_TY" id="select" title="EQ_TY">
<option>CE</option>
<option></option>
</select>
</strong></td>
<td>CE_TY</td>
<td><strong>
<input name="CE_TY" type="text" id="CE_TY" size="10" maxlength="10" title="CE_TY(max 6 digits)">
</strong></td>
</tr>
<tr>
<td height="32">STATUS</td>
<td><strong>
<select name="STATUS" id="select2" title="EQ_TY">
<option></option>
<option>-</option>
<option>Site Survey</option>
<option>Survey Done</option>
<option>Document Sent</option>
<option>Equipment Installed</option>
<option>Commissioned</option>
<option>Cancelled</option>
</select>
</strong></td>
<td>NO</td>
<td><strong>
<input name="NO" type="text" id="NO" size="3" maxlength="3" title="NO (max 7 digits)">
<input name="UNIT_DESC_NO" type="text" id="UNIT_DESC_NO" size="2" maxlength="2" title="UNIT_DESC_NO (max 1 digits)">
<input name="NO_ME_CCTS" type="text" id="NO_ME_CCTS" size="2" maxlength="2" title="NO_ME_CCTS (max 2 digits)">
<input name="Rack" type="text" id="Rack" size="2" maxlength="2" title="Rack (max 1 digits)">
<input name="INSTALL_BY" type="text" id="INSTALL_BY" size="2" maxlength="2" title="INSTALL_BY (max 2 digits)">
</strong></td>
</tr>
<td height="32"><font color="#000000" size="3" face="Georgia, Times New Roman, Times, serif">Order By</font></td>
<td colspan="5"><select name="oMDFnode">
<option value="STATUS">STATUS</option>
<option value="NO">NO</option>
<option value="CCP_CODE">CCP_CODE</option>
<option value="CCP_CODE">NODE_SITE_ID</option>
</select>
<select name="orMDFnode" id="orMDFnode">
<option value="NO">NO</option>
<option value="STATUS">STATUS</option>
<option value="CCP_CODE">CCP_CODE</option>
<option value="CCP_CODE">NODE_SITE_ID</option>
</select>
<select name="ordMDFnode" id="ordMDFnode">
<option value="CCP_CODE">NODE_SITE_ID</option>
<option value="CCP_CODE">NO</option>
<option value="CCP_CODE">STATUS</option>
<option value="CCP_CODE">CCP_CODE</option>
</select></td>
</tr>
</table>
<p align="center">
<input type="submit" name="Submit" value="Search">
<input type="reset" name="reset" value="Clear">
</p>
</form>
<form name="commNull" method="post">
<tr>
<td height="56" colspan="4"><div align="center">
</div></td>
</tr>
</form>
</body>
</html>
Display.asp
<% option explicit %>
<!-- METADATA TYPE = "typelib" File = "c:\Program Files\Common Files\System\ado\msado15.dll" -->
<%
dim strTitle
dim strF, fname, ropt, j, i, sno, ropt1
dim objRS, strQuery, strConn, strSort,strQuery1
dim strHref
dim nodesiteid
'dim eq_ty
'ropt1 = request("opt1")
ropt = request("opt")
'eq_ty = request("EQ_TY")
nodesiteid = request("NODE_SITE_ID")
strQuery1 = request("NODE_SITE_ID")
Set objRS = Server.CreateObject("ADODB.Recordset")
strConn = "Provider=MSDAORA.1;Password=hr;User ID=hr;Data Source=xe;Persist Security Info=True"
strSort = ""
strF = "CCP_CODE, NODE_SITE_ID, STREET_NAME, BLOCK_HOUSE, BLOCK_DESC_NO, UNIT_DESC_NO, BUILDING_NAME, EQ_RM, EQ_TY, CE_TY , Rack, INSTALL_BY, STATUS, NO, RFS_DATE, REMARK, NO_ME_CCTS, NO_ME_CCTS" 'these were fields in sql table as well as input name in form
fname= split(strF,",",-1,vbtextcompare) 'split the above string to individual field
if trim(strQuery1) ="" then
strQuery = "select rowid,CCP_CODE, NODE_SITE_ID, STREET_NAME, BLOCK_HOUSE, BLOCK_DESC_NO, UNIT_DESC_NO, BUILDING_NAME, EQ_RM, EQ_TY, CE_TY , Rack, INSTALL_BY, STATUS, NO, RFS_DATE, REMARK, NO_ME_CCTS from MDF_NODE where CCP_CODE = CCP_CODE"
else
strQuery = "select rowid,CCP_CODE, NODE_SITE_ID, STREET_NAME, BLOCK_HOUSE, BLOCK_DESC_NO, UNIT_DESC_NO, BUILDING_NAME, EQ_RM, EQ_TY, CE_TY , Rack, INSTALL_BY, STATUS, NO, RFS_DATE, REMARK, NO_ME_CCTS from MDF_NODE where CCP_CODE = CCP_CODE and NODE_SITE_ID="
strQuery = strQuery & "'" & strQuery1 & "'"
end if
strSort = " order by " & request("oMDFnode") & "," & request("orMDFnode") & "," & request("ordMDFnode")
strTitle = "Summary of Carrier Ethernet Node"
if trim(request("nfield"))= "" then
j=0
for i= 0 to ubound(fname)
if request(fname(i)) <> "" then 'process if user input value in field
if j=0 then
strQuery = strQuery & " and " & fname(i) & " like '" & request(fname(i)) & "' " '1st field shd start with where clause
j = j + 1
else
strQuery = strQuery & " and " & fname(i) & " like '" & request(fname(i)) & "' " 'rest shd start with and clause
j = j + 1
end if
end if
next
strQuery = strQuery & strSort
else
strQuery = strQuery & " where " & trim(request("nfield")) & " is null order by " & trim(request("order"))
end if
objRS.Open strQuery, strConn,adOpenStatic,adLockOptimistic,adCmdText 'open recordset query oracle database
if objRS.eof then
objRS.close
set objRS = nothing
response.write "<script>alert('No Rows Selected')</script>" 'if eof mean NO data return
response.write "<script>history.back()</script>"
else
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SdhTermDisplayTable2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#99CCFF"><div align="center">
<p align="left"><strong>
<p> </p>
<p>
</p>
</strong>
<table width=945 align="center">
<tr class="nonPrint" height=30>
<td width="646" nowrap style="vertical-align:middle;font:bolder 12pt verdana;" >
<strong> <font size="4" face="Georgia, Times New Roman, Times, serif"> </font><font size="4" face="Georgia, Times New Roman, Times, serif">
Records/font></strong></td>
</table>
<strong>
<%
if trim(request("nfield"))= "" then
j=0
for i= 0 to ubound(fname)
if request(fname(i)) <> "" then 'process if user input value in field
if j=0 then
strQuery = strQuery & " where " & fname(i) & " like '" & request(fname(i)) & "' " '1st field shd start with where clause
j = j + 1
else
strQuery = strQuery & " and " & fname(i) & " like '" & request(fname(i)) & "' " 'rest shd start with and clause
j = j + 1
end if
end if
next
strQuery = strQuery & strSort
else
strQuery = strQuery & " where " & trim(request("nfield")) & " is null order by " & trim(request("order"))
end if
if objRS.eof then
objRS.close
set objRS = nothing
response.write "<script>alert('No Rows Selected')</script>" 'if eof mean NO data return
response.write "<script>history.back()</script>"
else
call drawHeader(ropt)
objRS.movefirst
sno = sno + 1
do until objRS.eof
call drawB(fname)
sno = sno + 1
objRS.movenext
loop
objRS.close
set objRS = nothing
end if
sub drawHeader(ropt)
response.write "<table id='tbl' table border=1 bordercolor='black' bgcolor='LavenderBlush' cellpadding=1 cellspacing=0 align=center style='BORDER-COLLAPSE: collapse;'>"
select case ropt
case "MDFnode"
response.write "<tr height=20><td><b>SNo</b></td>"
response.write "<td style='font:bold 11pt;' width=50>Exch</b></td><td><b>Cabinet</b></td><td><b>Street Name</b></td><td><b>BLK/HSE</b></td><td><b>No</b></td><td><b>Unit</b></td><td><b>Building Name</b></td><td><b>Room</b></td><td><b>Type</b></td><td><b>Equipment Type</b></td><td><b>Rack</b></td><td><b>Inst By</b></td><td><b>Status</b></td><td><b>ID</b></td><td><b>RFS Date</b></td><td><b>Remark</b></td><td><b>No of ccts</b></td>"
end select
response.write"</tr>"
end sub
response.write"</table>"
sub drawbody(ropt)
response.write "<tr>"
select case ropt
case "MDFnode"
for i= 0 to 10
response.write "<td>" & i & "</td>"
next
end select
response.write"</tr>"
end sub
sub drawB(ofname)
response.write "<tr>"
for i = 0 to ubound(ofname)
if isnull(objRS(i)) then
response.write "<td> </td>"
else
if i = 0 then
strHref = "<a href='e_" & ropt & ".asp?tname=" & ropt & "&rowid=" & server.URLEncode(trim(objRS("rowid"))) & "'>" & sno & "</a>"
response.write "<td style='font:normal 12pt Arial;'>" & strHref & "</td>"
else
response.write "<td style='font:normal 12pt Arial;'>" & trim(objRS(i)) & "</td>"
end if
end if
next
response.write "</tr>"
end sub
end if
response.write"</table>"
%>
</strong></p> </div>
<div align="center">
<input type="button" value="Save as Excel" onClick="vbscript:xlsReport()">
</div>
</p>
</body>
</html>
<script language="VBScript">
dim r, c, colcnt,row
sub xlsReport()
window.status = "Export to Excel ... Please Wait ..."
dim rownow
colcnt = tbl.cells.length / tbl.rows.length
set xls = createobject("Excel.Application")
xls.visible = true
xls.workbooks.add
xls.worksheets.add
for c = 0 to colcnt - 1
xls.cells(3,c+1).value = tbl.rows(0).cells(c).innerText
next
row = 3
for r = 1 to tbl.rows.length -1
for c = 0 to colcnt - 1
xls.cells(row+r,c+1).value = tbl.rows(r).cells(c).innerText
next
next
xls.cells(1,1).value = txtRpt.innerText
set xls = nothing
window.status = "Done"
end sub
</script>
</div>
I am getting records based on CCP_Code and NODE_SITE_ID values.
Now I want to retrieve values only based on TYPE = 'CE' but I am not able to do this.
When I didn't select anything by default the TYPE value is 'CE'. Click submit and it gives me only type CE values.
When I give CCp_code with TYPE = empty then it should give me all the records based on CCP_Code.
When I select CCP_CODE and NODE_SITE_ID it should give me values based on both.
When I select CCP_CODE, NODE_SITE_ID and TYPE='CE' then it should give me values based on these values.
You need to Google "SQL injection" for a start.
strQuery = strQuery & "'" & strQuery1 & "'"
But as a start I'd log the contents of "strQuery" just before the objRS.Open
Once you can see the query text, it should be easy to say why rows were or were not returned.