Here I'm having no_of_devices which has three fields 'macAddress', 'useWith' and 'type' in a row, the count of row depends upon the number of devices selected from select field, so I'm using body-parser and i want to get all the row data which has name generated using for loop so all the rows having macAddress will have name='macAdd0',name="macAdd1" etc same goes with 'type' and 'useWith' field.
HTML
<select id="noOfDevice" class="form-control" name="noOfDevice" onchange="getDeviceCount(this)">
<option selected value="0">Select</option>
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
<option value="4">04</option>
<option value="5">05</option>
<option value="6">06</option>
<option value="7">07</option>
<option value="8">08</option>
<option value="9">09</option>
<option value="10">10</option>
</select>
Javascript
<script>
var macAdd;
var useWith;
var type;
var noOfDevice = req.body.noOfDevice;
for (var i = 0; i < noOfDevice; i++) {
var k = i.toString();
macAdd[i] = req.body.macAdd[i];
useWith[i] = req.body.useWith[i];
type[i] = req.body.type[i];
//console.log(req.body.macAdd);
process.deviceManger(macAdd[i], useWith[i], type[i]);
console.log('Device' + i + 'Details Update');
}
function getDeviceCount(sel) {
console.log("No of Device:" + sel.value);
var currCount = sel.value;
var div = document.createElement("div");
for (var i = 0; i < currCount; i++) {
div.setAttribute('id', 'addElements');
div.innerHTML += '<div class="row"><div class="form-row"><div class="form-group col-md-3"><label for="inputCity">Mac Address</label><input type="text" class="form-control" id="macAdd" name="macAdd' + i + '"></div> <div class="form-group col-md-3"><label for="inputState">Type of Device</label> <select id="inputState" class="form-control" name="deviceType' + i + '"> <option selected>Select</option> <option value="Irys Slate">Irys Slate</option> <option value="Irys Sling">Irys Sling</option> <option value="Irys Swing">Irys Swing</option> </select> </div> <div class="form-group col-md-3"> <label for="inputState">Use with</label> <select id="inputState" class="form-control" name="useWith' + i + '"> <option selected>Select</option> <option value="All">All</option> <option value="Nconnect">Nconnect</option> <option value="Tiara">Tiara</option> <option value="Corona">Corona</option> <option value="TiaraMini">TiaraMini</option> <option value="Nconnect+Tiara">Nconnect+Tiara</option> <option value="Nconnect+Corona">Nconnect+Corona</option> <option value="Nconnect+TiaraMini">Nconnect+TiaraMini</option> </select> </div> </div> </div>';
document.getElementById("devices").appendChild(div);
}
}
</script>
Related
is there a chance to search with evoSearch with 3 items? I would like the search results page to show the result only if the page meets all 3 conditions? TVs added to the document will be checkboxes with the possibility of multiple selection
Below is a screen that should help
https://imgur.com/a/1uKN2N0#t9hgC5x
Search page code
<form action="[~24~]" id="praca" method="get">
<div>
<label for="language">Language:</label>
<select type="text" name="language" id="language" class="form">
<option selected="" value="english">english</option>
<option value="spanish">spanish</option>
<option value="german">german</option>
<option value="polish">polish</option>
</select>
</div>
<div>
<label for="localisation">Localisation:</label>
<select type="text" name="localisation" id="localisation" class="form">
<option selected="" value="italy">Italy</option>
<option value="Greece">Greece</option>
<option value="Spain">Spain</option>
<option value="Portugese">Portugese</option>
</select>
</div>
<div>
<label for="category">Category:</label>
<select type="text" name="category" id="category" class="form">
<option selected="" value="it-service">IT service</option>
<option value="helpdesk">Helpdesk</option>
<option value="callcenter">Call center</option>
<option value="support">Support</option>
</select>
</div>
<button type="submit">Search</button>
</form>
Search results page
[!evoSearch?
&display=`10`
&filters=`AND(
content:c.template:notin:27,28;
content:c.id:notin:23,88;
)`
&tvPrefix=``
&tvList=`language,localisation,category`
&renderTV=`language,localisation,category`
&ownerTPL=`#CODE:[+dl.wrap+]`
&tpl=`evoSearch`
&statTpl=`<p>Showing results [+stat_from+] - [+stat_to+] of [+stat_total+] for "[+stat_request+]"</p>`
&noResult=`<p>Nothing was found for "[+stat_request+]"</p>`
!]
It can also be AjaxSearch, I have code like below, but unfortunately it searches for one criteria.
Adding advSearch = 'allwords' causes it to find nothing
[!AjaxSearch?
&clearDefault=`1`
&showResults=`0`
&landingPage=`12`
&showMoreResults=`1`
&moreResultsPage=`12`
&output=`0`
&whereSearch=`tv`
&withTvs=`category,language,localisation`
&tvPhx=`category,language,localisation`
&tplInput=`#FILE:assets/snippets/ajaxSearch/templates/inputTemplates/input3.tpl.html`
!]
input3.tpl.html code
[+as.showInputForm:is=`1`:then=`
<form id="[+as.formId+]" action="[+as.formAction+]" method="post">
<fieldset>
<div>
<label for="language">Language:</label>
<select name="search[]" id="ajaxSearch_select" class="form">
<option value="english">english</option>
<option value="spanish">spanish</option>
<option value="german">german</option>
<option value="polish">polish</option>
</select>
</div>
<div>
<label for="localisation">Localisation:</label>
<select name="search[]" id="ajaxSearch_select2" class="form">
<option selected="" value="italy">Italy</option>
<option value="Greece">Greece</option>
<option value="Spain">Spain</option>
<option value="Portugese">Portugese</option>
</select>
</div>
<div>
<label for="category">Category:</label>
<select name="search[]" id="ajaxSearch_select3" class="form">
<option selected="" value="it-service">IT service</option>
<option value="helpdesk">Helpdesk</option>
<option value="callcenter">Call center</option>
<option value="support">Support</option>
</select>
</div>
[+as.showAsId:is=`1`:then=`<input type="hidden" name="[+as.asName+]" value="[+as.asId+]" />`+]
<input type="hidden" name="advsearch" value="[+as.advSearch+]" />
<label>
<input id="[+as.submitId+]" type="submit" name="sub" value="[+as.submitText+]" />
</label>
</fieldset>
</form>
[+as.showIntro:is=`1`:then=`
<p class="ajaxSearch_intro" id="ajaxSearch_intro">[+as.introMessage+]</p>
`+]
`+]
When I select an option, I want to remove selected attribute from old one and add it to option I selected.
HTML Code:
<label>Gender</label>
<select id="gender" name="gender" class="form-control" onchange="redirect()">
<option value="male">Male</option>
<option value="female">Female</option>
<option value="any">Any</option>
</select>
JS Code:
<script>
$("#gender").on("change", function redirect() {
// const queryStr = "gender=any&platform=any"
// const usp = new URLSearchParams(queryStr)
// console.log(usp)
url = window.location.href.split("?")[0] + "?gender=" + this.value + "&platform=<%=platform%>"
location.replace(url)
})
</script>
When i am changing my option value of select it's ng-model value is not being changed.
Is this happening because of value is being changed by Jquery?
Because i read a line about angularjs from w3school that The ng-change event is only triggered if there is a actual change in the input value, and not if the change was made from a JavaScript.
And i want to clarify that option value is being changed by j query.
Please suggest me proper solution or tell me error in the code.
Here is my html
<div class="row" ng-app="myapp" ng-controller="mycontroller" id="mainController">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="form-group">
<p>Rooms
<% no_of_rooms %>
</p>
<select ng-init="no_of_rooms='1'" autocomplete="off" ng-model="no_of_rooms" class="form-control" id="no_of_rooms" style='display:none' name="no_of_room" style="height: 39px !important;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12" ng-repeat="i in getNumber(no_of_rooms) track by $index">
<div class="form-group">
<p>Adult (12+ YRS)</p>
<select autocomplete="off" class="form-control" style='display:none' name="no_of_adults[]" style="height: 39px !important;">
<option value="0">0</option>
<option value="1" Selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
</div>
</div>
</div>
Here is my script.
var app = angular.module('myapp', [], function($interpolateProvider) {
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
});
app.controller('mycontroller', function($scope , $filter) {
$scope.getNumber = function(num) {
return new Array(parseInt(num));
}
});
I want to scrape through web pages that are selected from drop down as shown below
<h1>Scraping Test</h1>
<form action="/tests/scraping" method='post'>
<input type="hidden" name="csrf_token" value="1499585369##d2d1570f820aec0589b3bd5f4ab4e7df913e25ff"/>
<table>
<tr>
<td>Select Ward: </td>
<td>
<select name="ward">
<option value=''>-- select --</option>
<option value='DHANLAXMICOMPLEX'>DHANLAXMICOMPLEX</option>
<option value='POTALIYA'>POTALIYA</option>
<option value='ARJUNTOWER'>ARJUNTOWER</option>
<option value='NEWCLOTHMARKET'>NEWCLOTHMARKET</option>
<option value='CHANAKYAPURI'>CHANAKYAPURI</option>
<option value='BHAIKAKANAGAR'>BHAIKAKANAGAR</option>
<option value='RADHASWAMYROAD'>RADHASWAMYROAD</option>
<option value='SATADHAR'>SATADHAR</option>
<option value='AMRUTAVIDYALAYA'>AMRUTAVIDYALAYA</option>
<option value='AGARWALTOWERS'>AGARWALTOWERS</option>
<option value='RANNAPARK'>RANNAPARK</option>
<option value='IIM'>IIM</option>
<option value='VEJALPURWARD'>VEJALPURWARD</option>
<option value='GITAMANDIR'>GITAMANDIR</option>
</select>
</td>
<td><input type="submit" value="Search" class="search"/></td>
</tr>
</table>
how to request a webpage from that drop down menu and there is also a search button
my code
import requests, csv
from lxml import html
def get_all_pages():
payload = {'value':'DHANLAXMICOMPLEX'}
url = requests.get('https://recruitment.advarisk.com/tests/scraping',data=payload)
print(url.text)
There is a token value which you can get from this HTML element
<input type="hidden" name="csrf_token" value="1499585369##d2d1570f820aec0589b3bd5f4ab4e7df913e25ff"/>
and use in your request. Try to use below code and let me know in case of any issues
import lxml.html
import requests
url = "https://recruitment.advarisk.com/tests/scraping"
s = requests.session()
r = s.get(url)
source = lxml.html.document_fromstring(r.content)
token = source.xpath('//input[#name="csrf_token"]/#value')[0]
headers = {'Referer': 'https://recruitment.advarisk.com/tests/scraping'}
data = {'csrf_token': token, 'ward': 'DHANLAXMICOMPLEX'}
print(s.post(url, data=data, headers=headers).text)
Looking to fill out a form in IE from a specific cell on my sheet; research has brought me to:
Function FillInternetForm()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://helppointinfo.farmersinsurance.com/OCR/Labor_Rates/laborrates.asp"
'go to web page listed inside quotes
ie.Visible = True
While ie.Busy
DoEvents 'wait until IE is done loading page.
Wend
ie.Document.all("RatesForm").Value = Sheets("NAT").Range("C2").Value
End Function
UPDATED
<html>
<head>
<meta name="GENERATOR" content="Microsoft Visual Studio 6.0" />
<title>Labor Rates</title>
<script language="javascript" type="text/javascript">
//Function is called when Enter Zip text box is changed or when Drill down zip is selected
function FindRates() {
if (document.RatesForm.DirectZip.value + "Empty" != "Empty" && document.RatesForm.ZipDD.value + "Empty" != "Empty") {
if (ValidateZip()) {
document.RatesForm.StateDD.value = ""
var strZipCode = document.RatesForm.ZipDD.value
document.getElementById("ErrorZip").style.display = "None"
document.getElementsByTagName("IFRAME").item("DisplayReport").src = "RatesHandler.asp?ZipCode=" + strZipCode
}
else {
document.getElementById("ErrorZip").style.display = "Block"
}
}
else if (document.RatesForm.DirectZip.value + "Empty" != "Empty") {
if (ValidateZip()) {
document.RatesForm.StateDD.value = ""
var strZipCode = document.RatesForm.DirectZip.value
document.getElementById("ErrorZip").style.display = "None"
document.RatesForm.submit();
document.getElementsByTagName("IFRAME").item("DisplayReport").src = "RatesHandler.asp?ZipCode=" + strZipCode
}
else {
document.getElementById("ErrorZip").style.display = "Block"
}
}
}
//Function called when State is selected from state Drop Down
function StateRates() {
var strState = document.RatesForm.StateDD.value
document.getElementsByTagName("IFRAME").item("DisplayReport").src = "RatesHandler.asp?State=" + strState
document.RatesForm.DirectZip.value = ""
document.RatesForm.ZipDD.value = ""
document.getElementById("ErrorZip").style.display = "None"
document.getElementById("TabTag").style.display = "None"
}
//Function Disables the Drill Down Zip to stop a double function issue
function disableDD() {
document.RatesForm.ZipDD.disabled = true;
document.getElementById("TabTag").style.display = "Block"
}
function ValidateZip() {
var re = /^\d{5}([\-]\d{4})?$/;
var testBool = re.test(document.RatesForm.DirectZip.value);
return (testBool);
}
function disableEnterKey(e) {
var key;
if (window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox
if (key == 13)
return false;
else
return true;
}
</script>
<link rel="stylesheet" type="text/css" href="css/main.css" />
</head>
<body>
<div class="DocumentTitle">Labor Rates Lookup</div>
<form name="RatesForm" method="post" >
<table class="SearchTable" border="0" cellpadding="0" cellspacing="0">
<tr class="SearchHeader">
<td colspan="2" >By Zip</td>
</tr>
<tr class="SearchRow">
<td>Enter Zip <br /><input class="SearchInput" id="DirectZip" name="DirectZip" value="" onkeypress="return disableEnterKey(event)" onblur="FindRates();" onfocus="disableDD();" /></td>
<td>
<span style="display:block;">Drill Down Zip<br />
<select disabled = "disabled" id="Select1" name="ZipDD" class="SearchSelect" style="width:200px;"onchange="FindRates();">
<option class='SearchSelect' selected='selected'>Please Enter Zip</option>
<option class='SearchSelect' selected='selected'></option>
</select>
</span>
</td>
</tr>
<tr class="SearchRow" style="text-align:center"><td colspan="2"><span id="ErrorZip" style="display:none;color:Red;">Please Enter a Valid US Zip Code!</span></td></tr>
<tr class="SearchRow" style="text-align:center"><td colspan="2"><span id="TabTag" style="display:none">Enter Zip Code and hit Tab.</span></td></tr>
<tr class="SearchHeader">
<td colspan="2" >By State</td>
</tr>
<tr class="SearchRow">
<td colspan="2" style="text-align:center;" >
<select id="ByState" name="StateDD" class="SearchSelect" onchange="StateRates();">
<option selected="selected"></option>
<option value = "AL" style='width:98%'>Alabama</option>
<option value = "AK" style='width:98%'>Alaska</option>
<option value = "AZ" style='width:98%'>Arizona</option>
<option value = "AR" style='width:98%'>Arkansas</option>
<option value = "CA" style='width:98%'>California</option>
<option value = "CO" style='width:98%'>Colorado</option>
<option value = "CT" style='width:98%'>Connecticut</option>
<option value = "DE" style='width:98%'>Delaware</option>
<option value = "DC" style='width:98%'>Dist. Columbia</option>
<option value = "FL" style='width:98%'>Florida</option>
<option value = "GA" style='width:98%'>Georgia</option>
<option value = "HI" style='width:98%'>Hawaii</option>
<option value = "ID" style='width:98%'>Idaho</option>
<option value = "IL" style='width:98%'>Illinois</option>
<option value = "IN" style='width:98%'>Indiana</option>
<option value = "IA" style='width:98%'>Iowa</option>
<option value = "KS" style='width:98%'>Kansas</option>
<option value = "KY" style='width:98%'>Kentucky</option>
<option value = "LA" style='width:98%'>Louisiana</option>
<option value = "ME" style='width:98%'>Maine</option>
<option value = "MD" style='width:98%'>Maryland</option>
<option value = "MA" style='width:98%'>Massachusetts</option>
<option value = "MI" style='width:98%'>Michigan</option>
<option value = "MN" style='width:98%'>Minnesota</option>
<option value = "MS" style='width:98%'>Mississippi</option>
<option value = "MO" style='width:98%'>Missouri</option>
<option value = "MT" style='width:98%'>Montana</option>
<option value = "NE" style='width:98%'>Nebraska</option>
<option value = "NV" style='width:98%'>Nevada</option>
<option value = "NH" style='width:98%'>New Hampshire</option>
<option value = "NJ" style='width:98%'>New Jersey</option>
<option value = "NM" style='width:98%'>New Mexico</option>
<option value = "NY" style='width:98%'>New York</option>
<option value = "NC" style='width:98%'>North Carolina</option>
<option value = "ND" style='width:98%'>North Dakota</option>
<option value = "OH" style='width:98%'>Ohio</option>
<option value = "OK" style='width:98%'>Oklahoma</option>
<option value = "OR" style='width:98%'>Oregon</option>
<option value = "PA" style='width:98%'>Pennsylvania</option>
<option value = "RI" style='width:98%'>Rhode Island</option>
<option value = "SC" style='width:98%'>South Carolina</option>
<option value = "SD" style='width:98%'>South Dakota</option>
<option value = "TN" style='width:98%'>Tennessee</option>
<option value = "TX" style='width:98%'>Texas</option>
<option value = "UN" style='width:98%'>Unknown</option>
<option value = "UT" style='width:98%'>Utah</option>
<option value = "VT" style='width:98%'>Vermont</option>
<option value = "VA" style='width:98%'>Virginia</option>
<option value = "WA" style='width:98%'>Washington</option>
<option value = "WV" style='width:98%'>West Virginia</option>
<option value = "WI" style='width:98%'>Wisconsin</option>
<option value = "WY" style='width:98%'>Wyoming</option>
</select>
</td>
</tr>
</table>
</form>
<div>
<iframe name="DisplayReport" id="DisplayReport" src="LaborCover.asp" frameborder="0" style="LEFT: 0%; WIDTH: 75%; TOP: 0%; HEIGHT:550px; BACKGROUND-COLOR:#CCCCCC; border:solid 0px black;"></IFRAME>
</div>
</body>
Banging my head against the wall on why I keep getting an error on the ie.document.all
Any help would be greatly appreciated.
CSS selector:
Piggybacking of the answer in the comment you can also use a CSS selector of #DirectZip.
This read as element with id of DirectZip. # means id.
CSS query:
VBA:
You use the .querySelector method of document to apply the CSS selector:
.document.querySelector("#DirectZip")