Hello I've got an issue with an encode failing. Can anyone spot where I'm going wrong?
<form>
<table cellspacing="0" cellpadding="0" border="0" style="background-color:#ededed;padding:50px;">
<tr>
<td align="left"><b>Screen? (eg. Index)</b></td>
</tr>
<tr>
<td align="left"><input type="text" name="strFeedbackScreen" value="" style="width:300px;"></td>
</tr>
<tr>
<td style="height:10px"></td>
</tr>
<tr>
<td align="left"><b>Comments:</b></td>
</tr>
<tr>
<td align="left"><textarea name="strFeedbackComments" style="width:400px;height:150px;"></textarea></td>
</tr>
<tr>
<td style="height:10px"></td>
</tr>
<tr>
<td align="left"><b>Thank you for your feedback.</b></td>
</tr>
<tr>
<td style="height:10px"></td>
</tr>
<cfoutput>
<tr>
<td align="left"><input type="button" value="Send" class="button"
onMouseover="this.className = 'buttonover';"
onMousedown="this.className = 'buttonover';"
onMouseOut="this.className = 'button';"
onclick="sendfeedback('strFeedbackScreen='+escape(this.form.strFeedbackScreen.value)+',strFeedbackComments='+escape(this.form.strFeedbackComments.value),'send_feedback_action_ajax')">
</td>
</tr>
</cfoutput>
</table>
</form>
is the form
<cfoutput>
<cfmail to="feedback#example.com" from="feedback#example.com" subject="Feedback left" type="html">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>**** This email has been sent to all concerned ****</td>
</tr>
<tr>
<td style="height:10px;"> </td>
</tr>
<cfif application.ds eq "App1">
<tr>
<td>This feedback has been left on App 1.</td>
</tr>
<cfelseif application.ds eq "App2">
<tr>
<td>This feedback has been left on App 2.</td>
</tr>
<cfelseif application.ds eq "App3">
<tr>
<td>This feedback has been left on App 3.</td>
</tr>
</cfif>
<tr>
<td style="height:10px;"> </td>
</tr>
<tr>
<td><b>From:</b></td>
</tr>
<tr>
<td>#session.stafffirstname# #session.staffsurname# - #session.staffemail#</td>
</tr>
<tr>
<td style="height:10px;"> </td>
</tr>
<tr>
<td><b>Screen:</b></td>
</tr>
<tr>
<td>#strFeedbackScreen#</td>
</tr>
<tr>
<td style="height:10px;"> </td>
</tr>
<tr>
<td><b>Comments:</b></td>
</tr>
<tr>
<td>#strFeedbackComments#</td>
</tr>
</table>
</cfmail>
</cfoutput>
is the action.cfm
and the javascript is
function sendfeedback(fields,action) {
turnLayeron('ajaxloading');
nocache = Math.random();
http.open('get', '/ajax.cfm?action='+action+'&fields='+fields+'&nocache='+nocache);
http.onreadystatechange = function() {
if(http.readyState == 4){
closepopout();
turnLayeroff('ajaxloading');
}
};
http.send(null);
}
I've been trying to get uriencode working, but it encodes my string before it gets emailed.
Change your JavaScript to following:
function sendfeedback(fields,action) {
http.open("POST", '/ajax.cfm?action='+action+'&nocache='+nocache, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {
if(http.readyState == 4){
closepopout();
turnLayeroff('ajaxloading');
}
};
http.send(fields);
}
Also change your function call to:
onclick="sendfeedback('strFeedbackScreen='+escape(this.form.strFeedbackScreen.value)+'&strFeedbackComments='+escape(this.form.strFeedbackComments.value),'send_feedback_action_ajax')"
Related
mrtg cfgmaker does read incorrect values over SNMP V1 and V2 and I need to correct the resulting file.
I would like to run a script after creation and use sed if possible.
Lines that needs to be corrected in my case are for LAG's and normal ports:
MaxBytes[switch01_lag_26]: 125000000 should go to MaxBytes[switch01_lag_26]: 250000000
(switch01_lag_26 can be switch01_lag_1 until switch01_lag_26)
MaxBytes[switch01_g1]: 12500000 should go to MaxBytes[switch01_g1]: 125000000
(switch01_g1 can be switch01_g1 until switch01_g16)
What sed patterns I have to use to analyze if its a lag or port in the square brackets and then replace the number after the : ?
The html part should show the correct speed if possible too, this is original for port g1:
<h1>Traffic Analysis for g1-- switch01</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>switch01</td>
</tr>
<tr>
<td>Maintainer:</td>
<td></td>
</tr>
<tr>
<td>Description:</td>
<td>1-Gigabit---Level </td>
</tr>
<tr>
<td>ifType:</td>
<td>ethernetCsmacd (6)</td>
</tr>
<tr>
<td>ifName:</td>
<td>g1</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>12.5 MBytes/s</td>
</tr>
<tr>
<td>Ip:</td>
<td>No Ip (No DNS name)</td>
</tr>
</table>
</div>
and should read at the end (Line below "Max Speed" is changed):
<h1>Traffic Analysis for g1-- switch01</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>switch01</td>
</tr>
<tr>
<td>Maintainer:</td>
<td></td>
</tr>
<tr>
<td>Description:</td>
<td>1-Gigabit---Level </td>
</tr>
<tr>
<td>ifType:</td>
<td>ethernetCsmacd (6)</td>
</tr>
<tr>
<td>ifName:</td>
<td>g1</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>125.0 MBytes/s</td>
</tr>
<tr>
<td>Ip:</td>
<td>No Ip (No DNS name)</td>
</tr>
</table>
</div>
This is original for LAG 1:
<h1>Traffic Analysis for lag 1 -- switch01</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>switch01</td>
</tr>
<tr>
<td>Maintainer:</td>
<td></td>
</tr>
<tr>
<td>Description:</td>
<td>lag-1 </td>
</tr>
<tr>
<td>ifType:</td>
<td>IEEE 802.3ad Link Aggregate (161)</td>
</tr>
<tr>
<td>ifName:</td>
<td>lag 1</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>125.0 MBytes/s</td>
</tr>
<tr>
<td>Ip:</td>
<td>No Ip (No DNS name)</td>
</tr>
</table>
</div>
which should read at the end (Line below "Max Speed" is changed):
<h1>Traffic Analysis for lag 1 -- switch01</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>switch01</td>
</tr>
<tr>
<td>Maintainer:</td>
<td></td>
</tr>
<tr>
<td>Description:</td>
<td>lag-1 </td>
</tr>
<tr>
<td>ifType:</td>
<td>IEEE 802.3ad Link Aggregate (161)</td>
</tr>
<tr>
<td>ifName:</td>
<td>lag 1</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>250.0 MBytes/s</td>
</tr>
<tr>
<td>Ip:</td>
<td>No Ip (No DNS name)</td>
</tr>
</table>
</div>
I can change all speeds in HTML using sed -i 's/\([0-9.]\+\) MBytes/125.0 MBytes/' /switch01.cfg but this changes for LAG's too. How to detect if the HTML part belongs to a LAG?
In the html below, I'm trying to get the two nodes that contain values for shipment_number, but instead I get 6 <td> nodes - why? Doesn't contains limit the nodes to only those that match the text value? If so the statement below should only return two, not six?
In Chrome dev console:
$x("//tr//td[contains(.,'shipment number')]/following::td[1]")
html:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<table border="1">
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td>Date</td>
<td>11/15/2019</td>
</tr>
<tr>
<td>shipment number</td>
<td>abc_123_florida-45</td>
</tr>
<tr>
<td>Departure time:</td>
<td>0430</td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td>Time arrival</td>
<td>1715</td>
</tr>
<tr>
<td>customer</td>
<td>bob smith</td>
</tr>
<tr>
<td>box type</td>
<td>square</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table border="1">
<tbody>
<tr>
<td>
<table>
<tbody>
<tr name="laneStop">
<td>box1</td>
<td>23.45</td>
<td>lane1</td>
<td>south</td>
</tr>
<tr name="laneStop">
<td>box2</td>
<td>17.14</td>
<td>lane1</td>
<td>south</td>
</tr>
<tr name="laneStop">
<td>box3</td>
<td>17.18</td>
<td>lane1</td>
<td>north</td>
</tr>
<tr name="laneStop">
<td>box2</td>
<td>199.14</td>
<td>lane1</td>
<td>west</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table border="1">
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td>Date</td>
<td>11/16/2019</td>
</tr>
<tr>
<td>shipment number</td>
<td>abc_222_florida-35</td>
</tr>
<tr>
<td>Departure time:</td>
<td>0630</td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td>Time arrival</td>
<td>1715</td>
</tr>
<tr>
<td>customer</td>
<td>sue smith</td>
</tr>
<tr>
<td>box type</td>
<td>rect</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table border="1">
<tbody>
<tr>
<td>
<table>
<tbody>
<tr name="laneStop">
<td>box1</td>
<td>33.45</td>
<td>lane1</td>
<td>south</td>
</tr>
<tr name="laneStop">
<td>box2</td>
<td>1.14</td>
<td>lane1</td>
<td>south</td>
</tr>
<tr name="laneStop">
<td>box3</td>
<td>27.18</td>
<td>lane1</td>
<td>north</td>
</tr>
<tr name="laneStop">
<td>box2</td>
<td>299.14</td>
<td>lane1</td>
<td>west</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>
You need
//tr//td[contains(text(),'shipment number')]/following::td[1]
That's because contains(., '...') converts . to string by expanding all its text descendants, not just children.
I'm adding this answer because text() node test might conflict with others requirements, mainly those dealing with inline markup.
The reason because you are getting six td elements is that there is six td having "shipment number" as part of theirs string value (concatenation of all descendant text nodes). And that is because you have nested tables, thus nested td elements. So, you want a td element not having a descendant td element.
The expression:
//tr//td[not(.//td)][contains(.,'shipment number')]/following::td[1]
It selects:
<td>abc_123_florida-45</td>
<td>abc_222_florida-35</td>
Check in http://www.xpathtester.com/xpath/37bd889231ad68bb7bfa377433aeca00
Do note that your input sample has a default namespace declaration with the namespace URI http://www.w3.org/1999/xhtml. Because niether your code sample nor your selected answer are ussing namespaces, I asume you know how to work with them.
I have a HTML like
<body>
<tr class="sysinfoTableCategoryHeader">
<td colspan="4">Operating System</td>
</tr>
<tr class="sysinfoTablePropertyEven">
<td />
<td />
<td><span class="sysinfoTablePropertyKey">Operating System Name</span></td>
<td><span class="sysinfoTablePropertyValue">Linux</span></td>
</tr>
<tr class="sysinfoTablePropertyOdd">
<td />
<td />
<td><span class="sysinfoTablePropertyKey">Kernel Version</span></td>
<td><span class="sysinfoTablePropertyValue">4.8.0-1-amd64</span></td>
</tr>
<tr class="sysinfoTableCategoryHeader">
<td colspan="4">Motherboard</td>
</tr>
<tr class="sysinfoTablePropertyEven">
<td />
<td />
<td><span class="sysinfoTablePropertyKey">Manufacturer</span></td>
<td><span class="sysinfoTablePropertyValue">Acer</span></td>
</tr>
<tr class="sysinfoTablePropertyOdd">
<td />
<td />
<td><span class="sysinfoTablePropertyKey">Product</span></td>
<td><span class="sysinfoTablePropertyValue">Aspire E5-531</span></td>
</tr>
</body>
So I'm able to pick entire body from this html file which is actually awesome. But there is one problem . Lets say from that body i want to ignore the node with class name="sysinfoTableCategoryHeader" Operating system.
Is this doable at all ?
My output should be like this
<body>
<tr class="sysinfoTableCategoryHeader">
<td colspan="4">Motherboard</td>
</tr>
<tr class="sysinfoTablePropertyEven">
<td />
<td />
<td><span class="sysinfoTablePropertyKey">Manufacturer</span></td>
<td><span class="sysinfoTablePropertyValue">Acer</span></td>
</tr>
<tr class="sysinfoTablePropertyOdd">
<td />
<td />
<td><span class="sysinfoTablePropertyKey">Product</span></td>
<td><span class="sysinfoTablePropertyValue">Aspire E5-531</span></td>
</tr>
</body>
How can i acoomplish it with HTMLAGILITYPACK ??
I'm english a little.
exp code:
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(your html code);
HtmlNodeCollection htmlNodes = htmlDoc.DocumentNode.SelectNodes("//body/tr[#class!='sysinfoTableCategoryHeader']");
the htmlNodes is you needs.
Or use RemoveAllIDforNode();
HtmlNodeCollection htmlNodes = htmlDoc.DocumentNode.SelectNodes("//body/tr[#class='sysinfoTableCategoryHeader']");
foreach (HtmlNode node in htmlNodes) {
htmlDoc.DocumentNode.RemoveAllIDforNode(node);
}
you need find xpath //tr[#class!='sysinfoTableCategoryHeader']
the xpath have operator.
Sometime working and sometime not.
I am trying to generate Grid with the help of JQuery Template via Ajax once record is added or deleted. In js file
$('.gridRow').remove();
is not working properly. Someone tell me how to reset grid to fill it again. Below is the code.
JS File
var ReloadGrid = (function(){
$.getJSON("/HeaderMenu/GetHeaderGrid", function(data) {
$('.gridRow').remove();
(data.length <= 0) ? $("#gridBtn").hide() : $("#gridBtn").show();
for (var i=0; i<data.length; i++) { data[i].num = i+1; }
$('#gridTemplate').tmpl(data).appendTo('table.gridTable > tbody');
});
});
on MVC3 cxhtml page
<script id="gridTemplate" type="text/x-jquery-tmpl">
<tr class="gridRow">
<td class="cellTd ">
<input type="checkbox" id="deleteCb" />
<input type="hidden" id="Id_ + ${num}" class="idField" value="${Id}" />
</td>
<td class="cellTd">
<input id="index" name="index" class="numberField" type="text" value="${IndexOrder}" />
</td>
<td class="cellTd">${DisplayName}</td>
<td class="cellTd ">${UrlName}</td>
<td class="cellTd ">
<input type="checkbox" id="activeCb" {{if Active}} checked{{/if}} />
</td>
</tr>
</script>
<div class="gridDiv">
<table class="gridTable" cellspacing="0" cellpadding="0">
<tbody>
<tr class="gridTitleRow">
<td class="iconLink width36">Delete</td>
<td class="iconLink width60">Sort Order</td>
<td class="iconLink widthAuto">Display Name</td>
<td class="iconLink widthAuto">Url Name</td>
<td class="iconLink widthAuto">Active</td>
</tr>
</tbody>
</table>
</div>
I usually empty the wrapper instead of the row.
$('table.gridTable > tbody').empty();
But for that to work you'd have to change your table to use thead
<table class="gridTable" cellspacing="0" cellpadding="0">
<thead>
<tr class="gridTitleRow">
<th class="iconLink width36">Delete</th>
<th class="iconLink width60">Sort Order</th>
<th class="iconLink widthAuto">Display Name</th>
<th class="iconLink widthAuto">Url Name</th>
<th class="iconLink widthAuto">Active</th>
</tr>
<thead>
<tbody>
</tbody>
</table>
I have this form
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<tr>
<td width="32%" valign="top"> <strong class="main_title">Select Category: </strong></td>
<td width="68%" valign="top" class=""><? $qu="SELECT `id`,`name` FROM `linkvideos_category` WHERE `status` = '1'"; $rs=$Q($qu); ?>
<select name="category" class="blacktext" >
<option>Choose Category</option>
<? while($dis=$F($rs)) { ?>
<option value="<?=$dis['id']?>"> <?=$dis['name'];?></option>
<? } ?>
</select></td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td valign="top"> <strong class="main_title">Upload Image: </strong></td>
<td valign="top" class=""><input type="file" name="imagefile" /> </td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td valign="top"> <strong class="main_title"> Your Link : </strong></td>
<td valign="top" class=""><input name="link" type="text" size="50" /></td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td valign="top"> <strong class="main_title"> Link Title : </strong></td>
<td valign="top" class=""><input name="linkname" type="text" size="50" /></td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td valign="top"> <strong class="main_title">Description:</strong></td>
<td valign="top"><label>
<textarea name="desc" cols="40" rows="10"></textarea>
</label></td>
</tr>
<tr>
<td valign="top"> <strong class="main_title">Security Code:</strong></td>
<td valign="top">
<? if ($error==3) { ?>
<font color="red">Invalid Code Entered</font>
<?}?>
<?php
require_once('captcha/recaptchalib.php');
echo recaptcha_get_html($public_key);
?></td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td colspan="2" valign="top" class=""> </td>
</tr>
<tr>
<td colspan="2" align="center" valign="top" class=""><input type="submit" name="Submit" value="Submit" class="btns" onclick="javascript:return check();" /></td>
</tr>
</form>
and i'm verifying the captcha with this
$resp = recaptcha_check_answer ($private_key,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error = 3;
echo"<script>window.location='submit_linkvideo.php?error=3';</script>";
}
and every time it's telling me the captchas invalid and saying incorrect-captcha-sol, am I missing something? I've tested it and the recaptcha values arn't being submitted.
Fixed it by ending a table before the form then starting the table again once inside the form.