looking for some help here please. So, I have a page that list the users from a group using the groupID as the parameter. Sometimes these list of users could be really long and I wanted to build in a search functionality to search the user(member) of the group.
I access the Workspace Directory API and method members.list like this:
const groupUsers = async function (groupid, from) {
var members = [];
var pageToken = '';
var newPageToken = '';
const admin = await authorizeDirectory();
const resp = await admin.members.list({
groupKey: groupid,
});
members = resp.data.members;
console.log(members);
// console.log(members);
// members = resp.data.members;
const total = members.length;
return { results: members.splice(from, 10), total };
};
I then pass the response back to an index.js file that handles it for rendering to a handlebars template. Inside this template I have form that allows the user to enter the email address so that I can use it to search for it directly from the members.get method
My code for that is:
<div class="searchWrapper">
<form action="/group" method="GET" class="searchBar">
<input type="text" name="searchBar" id="searchBar" placeholder="Enter the user's email ID"
value="{{this.term}}" />
<span class="search-button">
<a class="waves-effect waves-light btn-small" id="searchButton">FIND</a>
</span>
</form>
</div>
Could someone please help me understand how do I send the groupID and the value entered in the input search bar to the method, so that I can query the API. Would really appreciate the help.
My routes:
router.get('/group/:groupid', isUserAuthenticated, async (req, res) => {
const groupid = req.params.groupid;
const from = parseInt(req.query.from || 0, 10) || 0;
const members = await groupUsers(groupid, from);
const pages = [];
for (var i = 0; i < Math.ceil(members.total / 10); i++)
pages.push({ page: i * 10, label: i + 1 });
res.render('groups', {
members: members.results,
total: members.total,
groupid: groupid,
from: from,
pages: pages,
});
// res.send(`Group ID = ${req.params.groupid}`);
});
I am trying to do IE Automation through Excel VBA code.
I have a web page which has cells to add value. I need to change values in these cells by code vba excel
example:
Now cells in webpage has value : "11_now test"
My code vba excel:
ie.Document.getelementbyid("mx7125[R:0"]").Value = "Good" ' value i want to set
When run vba , webpage show value at cell is "Good" but when i click save button, the value at cell is "11_now_test"
HTML code is as below:
<input aria-labelledby="" id="mx7125[R:0]" class="fld text tt" ctype="textbox" li="mx7126[R:0]" db="mx5134" maxlength="200" style=";width:300px;" ontr='true' async='1' ae="setvalue" type="text" title="Remark: 11_now_test" value="11_now_test" ov="11_now_test" work="1" fldInfo='{"length":"200","inttype":"0"}'/></div><div aria-live="polite" id="mx7126[R:0]_holder" class="bc"><img sf="1" aria-hidden="true" active="0" ctype="image" alt="" src="../webclient/skins/skins-20171010-1330/tivoli09/images/blank.gif" source="blank" imgtype=".gif" style="display:inline;margin:0px;" border="0" lc="mx7125[R:0]" align="absmiddle" width='0px' height='26px' id="mx7126[R:0]" title=""/></div></td>
* More information*
Dear bros
when i press F12 to inspector on webpage. If click to change value on webpage, html code at this time is:
<input aria-labelledby="" id="mx7125[R:0]" class="fld text tt" ctype="textbox" li="mx7126[R:0]" db="mx5134" maxlength="200" style=";width:300px;" ontr="true" async="1" ae="setvalue" type="text" title="Remark: 11 Nov test" value="11 Nov test" ov="11 Nov test" work="1" fldinfo="{"length":"200","inttype":"0"}" originalvalue="11 Nov test" prekeyvalue="good" stoptcclick="true" keydown="false" changed_by_user="true" changed="true">
When type value " Good" to input cell on webpage ,prekeyvalue ="Good" and keydown will turn "True" then keydown back to "false"
* Javascrip at input cell *
when click to change value at input cell i found javascrip :
function tb_(eventOrComponent)
{
eventOrComponent = (eventOrComponent) ? eventOrComponent : ((window.event) ? window.event : "");
var eventType = eventOrComponent.type;
var textbox = this;
if(undef(eventType) || eventType=="text") {
eventType = "init";
textbox = eventOrComponent;
}
if(DESIGNMODE)
return;
var ro = textbox.readOnly;
var exc=(textbox.getAttribute("exc")=="1");
switch(eventType)
{
case "init":
setPromptValue(textbox.id);
break;
case "mousedown":
if(getFocusId()==this.id)
this.setAttribute("stoptcclick","true");
break;
case "mouseup":
if (isIE() && !hasFocus(this))
{
this.focus();
}
if (isBidiEnabled)
{
adjustCaret(eventOrComponent, this);
}
break;
case "blur":
input_onblur(eventOrComponent,this);
if (isBidiEnabled)
input_bidi_onblur(eventOrComponent, this);
break;
case "change":
if(!ro)
input_changed(eventOrComponent,this);
break;
case "click":
if(overError(eventOrComponent,this))
showFieldError(eventOrComponent,this,true);
var liclick=this.getAttribute("liclick");
var li=this.getAttribute("li");
if(li!="" && liclick=="1")
{
frontEndEvent(getElement(li),'click');
}
if(this.getAttribute("stoptcclick")=="true")
{
eventOrComponent.cancelBubble=true;
}
this.setAttribute("stoptcclick","false");
break;
case "focus":
input_onfocus(eventOrComponent,this);
if (isBidiEnabled)
input_bidi_onfocus(eventOrComponent, this);
this.select();
this.setAttribute("prekeyvalue",this.value);
break;
case "keydown":
this.setAttribute("keydown","true");
if(!ro)
{
lastKeyPress = eventOrComponent.keyCode;
if(eventOrComponent.ctrlKey && hasKeyCode(eventOrComponent,'KEYCODE_SPACEBAR')) {
stopBubble(eventOrComponent);
eventOrComponent.cancelBubble=true;
eventOrComponent.returnValue=false;
break;
}
if(isBidiEnabled)
processBackspaceDelete(eventOrComponent,this);
if(hasKeyCode(eventOrComponent, 'KEYCODE_DELETE') || hasKeyCode(eventOrComponent, 'KEYCODE_BACKSPACE'))
{
getHiddenForm().elements.namedItem("changedcomponentvalue").value = this.value;
}
if((hasKeyCode(eventOrComponent, 'KEYCODE_TAB') || hasKeyCode(eventOrComponent, 'KEYCODE_ESC')))
{
var taMatch = dojo.attr(this, "ta_match");
if(taMatch) {
if(taMatch.toLowerCase().indexOf(this.value.toLowerCase()) == 0)
{
console.log("tamatch="+taMatch);
this.value = taMatch;
input_keydown(eventOrComponent, this);
dojo.attr(this, {"prekeyvalue" : ""});
input_forceChanged(this);
inputchanged = false;
return; // don't want to do input_keydown again so preKeyValue will work
}
}
if(this.getAttribute("PopupType"))
{
var popup = dijit.byId(dojohelper.getPopupId(this));
if (popup)
{
dojohelper.closePickerPopup(popup);
if(hasKeyCode(eventOrComponent, 'KEYCODE_ESC'))
{
if (eventOrComponent.preventDefault)
{
eventOrComponent.preventDefault();
}
else
{
eventOrComponent.returnValue = false;
}
return;
}
}
}
}
input_keydown(eventOrComponent,this);
datespin(eventOrComponent,this);
}
else if(hasKeyCode(eventOrComponent,'KEYCODE_ENTER') || (hasKeyCode(eventOrComponent,'KEYCODE_DOWN_ARROW') && this.getAttribute("liclick")))
{
var lbId = this.getAttribute("li");
frontEndEvent(getElement(lbId), 'click');
}
else if(hasKeyCode(eventOrComponent,KEYCODE_BACKSPACE))
{
eventOrComponent.cancelBubble=true;
eventOrComponent.returnValue=false;
}
break;
case "keypress":
if(!ro)
{
lastKeyPress = eventOrComponent.keyCode;
if(eventOrComponent.ctrlKey==false && hasKeyCode(eventOrComponent,'KEYCODE_ENTER'))
{
var db = this.getAttribute("db");
if(db && db!="")
{
input_forceChanged(this);
sendClick(db);
// IV32363 - When default button is a new row button, then we must set focus on
// the button or the value in text box will be copied to the new row
if (db)
{
window.setTimeout("focusElement(document.getElementById('"+db+"'))", 10);
}
}
}
}
break;
case "keyup":
var keyDown = this.getAttribute("keydown");
this.setAttribute("keydown","false");
if(eventOrComponent.ctrlKey && hasKeyCode(eventOrComponent,'KEYCODE_SPACEBAR'))
{
if(showFieldError(eventOrComponent,this,true))
{
return;
}
else
{
menus.typeAhead(this,0);
}
}
if(!ro)
{
if(isBidiEnabled)
processBidiKeys(eventOrComponent,this);
numericcheck(eventOrComponent,this);
var min = this.getAttribute("min");
var max = this.getAttribute("max");
if(min && max && min!="NONE" || max!="NONE")
{
if(min!="NONE" && parseInt(this.value)<parseInt(min))
{
this.value=min;
getHiddenForm().elements.namedItem("changedcomponentvalue").value = this.value;
this.select();
return false;
}
if(max!="NONE" && parseInt(this.value)>parseInt(max))
{
this.value=max;
getHiddenForm().elements.namedItem("changedcomponentvalue").value = this.value;
this.select();
return false;
}
}
var defaultButton = false;
if(eventOrComponent.ctrlKey==false && hasKeyCode(eventOrComponent,'KEYCODE_ENTER'))
{
var db = this.getAttribute("db");
if(db && db!="")
{
defaultButton=true;
}
}
input_changed(eventOrComponent,this);
}
else
{
setFocusId(eventOrComponent,this);
}
if(showFieldHelp(eventOrComponent, this))
{
return;
}
if(keyDown=="true" && hasKeyCode(eventOrComponent, 'KEYCODE_ENTER') && !eventOrComponent.ctrlKey && !eventOrComponent.altKey)
{
menus.typeAhead(this,0);
return;
}
if(!hasKeyCode(eventOrComponent, 'KEYCODE_ENTER|KEYCODE_SHIFT|KEYCODE_CTRL|KEYCODE_ESC|KEYCODE_ALT|KEYCODE_TAB|KEYCODE_END|KEYCODE_HOME|KEYCODE_RIGHT_ARROW|KEYCODE_LEFT_ARROW')
&& !eventOrComponent.ctrlKey && !eventOrComponent.altKey)
{
menus.typeAhead(this,0);
}
break;
case "mousemove":
overError(eventOrComponent,this);
break;
case "drop":
input_onfocus(eventOrComponent,this);
if (isBidiEnabled)
{
input_bidi_onfocus(eventOrComponent, this);
}
this.select();
if(!ro)
{
this.setAttribute("prekeyvalue",this.value);
}
case "cut":
case "paste":
if(!ro)
{
var fldInfo = this.getAttribute("fldInfo");
if(fldInfo)
{
fldInfo = dojo.fromJson(fldInfo);
if(!fldInfo.query || fldInfo.query!=true)
{
setButtonEnabled(saveButton,true);
}
}
window.setTimeout("inputchanged=true;input_forceChanged(dojo.byId('"+this.id+"'));", 20);
}
break;
}
}
* HIDDEN FORM *
Dear #Zhi Lv - MSFT ! i tried sendkeys method but not success! i found the same problem at this link. Extractly that i want to change value in maximo website, has hiddenform but at that linked they use javascript, don't use IE automation vba excel.When i inspect at input cells and type document.getelementbyid("hiddenform") , found this hiddenform:
<form aria-hidden="true" id="hiddenform" name="hiddenform" method="POST" action="http://maximo.mysite.com/maximo/ui/maximo.jsp" style="padding:3px;">
<input type="text" size="45" name="event" id="event" title="event type"><br>
<input type="text" size="45" name="targetid" id="targetid" title="target id"><br>
<input type="hidden" size="45" name="value" id="value" value=""><!-- this must be type hidden to support \n in the value -->
<input type="text" size="45" name="changedcomponentid" id="changedcomponentid" title="changed component id"><br>
<input type="text" size="45" name="vischangedcomponentvalue" id="vischangedcomponentvalue" title="changed component value"><br>
<input type="hidden" name="changedcomponentvalue" value="">
<input type="text" size="45" name="currentfocus" id="currentfocus" title="focus id"><br>
<input name="scrollleftpos" id="scrollleftpos" size="45" title="Scroll Left"><br>
<input name="scrolltoppos" id="scrolltoppos" size="45" title="Scroll Top"><br>
<input type="text" size="45" name="uisessionid" id="uisessionid" value="4770" class="fld_ro" readonly="readonly" title="ui session id"><br>
<input type="text" size="45" name="csrftokenholder" id="csrftokenholder" value="ocvdjoiuq2ht8detn26pkjeekg" title="CSRF Token" readonly="readonly" class="fld_ro"><br>
</form>
thanks!!!
How do you get the input text value when click the save button? I have created a sample using the following code, it works well on my side. Please refer to it.
IE.Document.getelementbyid("mx7125[R:0]").Value = "Good"
And web page resource as below (using javascript script get the value document.getElementById('mx7125[R:0]').value):
<div>
<input aria-labelledby="" id="mx7125[R:0]" class="fld text tt" ctype="textbox" li="mx7126[R:0]"
db="mx5134" maxlength="200" style="width:300px;" ontr='true' async='1' ae="setvalue" type="text"
title="Remark: 11_now_test" value="11_now_test" ov="11_now_test" work="1" fldInfo='{"length":"200","inttype":"0"}' />
</div>
<div aria-live="polite" id="mx7126[R:0]_holder" class="bc">
<img sf="1" aria-hidden="true" active="0" ctype="image" alt="" src="../webclient/skins/skins-20171010-1330/tivoli09/images/blank.gif" source="blank" imgtype=".gif"
style="display:inline;margin:0px;" border="0" lc="mx7125[R:0]" align="absmiddle" width='0px' height='26px' id="mx7126[R:0]" title="" /></div>
<input id="btnSubmit" type="button" value="Submit" onclick="Javascript: alert(document.getElementById('mx7125[R:0]').value);" />
If still not working, please post the related code about the save button.
I'am sure there are events to the input fields. Like onChange(), onFocus(), onBlur() and/ or others. You can find out it if you press F12 on the tab with the opened page. Track through the tree of the DOM Inspector. In the row with your code snippet will be a button with the caption "event" at end of line. With a click on the button you can see which events there are.
In the past it was possible to trigger an event with fireEvent(). Another way is dispatchEvent() with some other methods like initEvent().
The words between [] are "outdated" ;-)
[What ever I tryed in the past, nothing worked. So I can't tell how you can solve your problem but I' am sure it is an event problem.]
This link shows you how it should work:
Vba, HTMLSelect: FireEvent OnChange or DispatchEvent
The words between [[]] are not relevant for IE11
[[Another more modern way is *addEventListener()*. But I don't know with which method the IE11 is working:
EventTarget.addEventListener()
The problem for me with *addEventListener()* is, the IE has not eventTarget() Constructer (see browser compatibility table at the bottom of the page):
EventTarget()]]
Edit 1:
In IE11 it works with dispatchEvent() and the other relevant things. You must place all commands in an own method. Two examples:
For onChange() use:
Private Sub Event_onChange(htmlDocument As Object, htmlElementWithEvent As Object)
Dim Event_onChange As Object
htmlElementWithEvent.Focus
Set Event_onChange = htmlDocument.createEvent("HTMLEvents")
Event_onChange.initEvent "change", True, False
htmlElementWithEvent.dispatchEvent Event_onChange
End Sub
For onKeyDown() use :
Private Sub Event_onKeyDown(htmlDocument As Object, htmlElementWithEvent As Object)
Dim Event_onKeyDown As Object
htmlElementWithEvent.Focus
Set Event_onKeyDown = htmlDocument.createEvent("HTMLEvents")
Event_onKeyDown.initEvent "onkeydown", True, False
htmlElementWithEvent.dispatchEvent Event_onKeyDown
End Sub
I know that now because we disscuss this right now in a german forum. The solution with the own sub() is from the user Anton (not involved in the discussion). With Antons sub() I figure out right now how the German Post will let a macro insert adresses in an order blank.
The german discussion:
Webformular (DHL) ausfüllen
Or after one week in the archive:
Webformular (DHL) ausfüllen (archive thread)
Edit 2:
I think you must trigger the onKeyDown event. Try the following:
Dim nodeInput As Object
Set nodeInput = ie.Document.getelementbyid("mx7125[R:0]")
Call TriggerEvent(ie.Document, nodeInput, "onKeyDown")
nodeInput.Value = "Good"
Here is the function to trigger an event like QHarr wrote in the comments with the event type as third function parameter:
Private Sub TriggerEvent(htmlDocument As Object, htmlElementWithEvent As Object, eventType As String)
Dim theEvent As Object
htmlElementWithEvent.Focus
Set theEvent = htmlDocument.createEvent("HTMLEvents")
theEvent.initEvent eventType, True, False
htmlElementWithEvent.dispatchEvent theEvent
End Sub
In the above linked german forum the Deutsche Post form works now with this function. But it is necessary to put in all values two times.
We don't know anything about your page. The url seems to be a secret. If you need more help we need more infos.
I want to send the value of textbox to the Action Method for searching the technology for that i want to get the value of textbox in Action.
I have the following code :-
#Html.TextBox("technologyNameBox", "", new { id = "technologyName", #class = "form-control", #placeholder = "Search For Technology" })
<span class="input-group-btn" style="text-align:left">
<a class="btn btn-default" id="searchTechnology"
href="#Url.Action("SearchTechnology", "Technology",
new {technologyName="technologyName",projectId=ProjectId })">
<span class="glyphicon glyphicon-search "></span>
</a>
</span>
Question :- How to get the value of textbox "technologyNameBox" in Action ?
Please help me out. Thanks in Advance!
You'd have to append the value to the URL via JavaScript before directing the user. Using jQuery (since that generally comes packaged with ASP.NET), it might look something like this (with a good bit of manual conditional checks for blank values or query string parameters):
$('#searchTechnology').click(function (e) {
e.preventDefault();
var url = '#Url.Action("SearchTechnology", "Technology", new { projectId=ProjectId })';
var technologyName = $('#technologyName').val();
if (technologyName.length < 1) {
// no value was entered, don't modify the url
window.location.href = url;
} else {
// a value was entered, add it to the url
if (url.indexOf('?') >= 0) {
// this is not the first query string parameter
window.location.href = url + '&technologyName=' + technologyName;
} else {
// this is the first query string parameter
window.location.href = url + '?technologyName=' + technologyName;
}
}
return false;
});
The idea is that when the user clicks that link, you would fetch the value entered in the input and append it to the URL as a query string parameter. Then redirect the user to the new modified URL.
How can I add fields dynamically in Jtable. I want to have multiple values for Cities
Please Refer the image attached
Thanks
Yes this is not built-in with jQuery jTable. To deal with this I've created a script for the same purpose. This handles (a) adding more controls OR group of controls and (b) remove control(s).
Here is the script:
//add '.add_more' class to
$(".add_more").on('click', function () {
// creates unique id for each element
var _uniqueid_ = +Math.floor(Math.random() * 1000000);
var new_ele_id = $(this).attr("data-clone-target") + _uniqueid_;
var cloneObj = $("#" + $(this).attr("data-clone-target"))
.clone()
.val('')
.attr("id", new_ele_id);
// if the control is grouped control
if ($(this).hasClass('group_control') == true) {
$($(cloneObj).children()).each(function () {
$(this).attr("id", $(this).attr("id") + _uniqueid_).val("");
});
}
$(cloneObj).insertBefore($(this));
//creates a 'remove' link for each created element or grouped element
$("<a href='javascript:void(0);' class='remove_this' data-target-id='" + new_ele_id + "'></a>")
.on('click', function () {
if ($(this).is(":visible") == true) {
if (confirm("Are you sure?")) {
$("#" + $(this).attr("data-target-id")).remove();
$(this).remove();
}
}
else {
$("#" + $(this).attr("data-target-id")).remove();
$(this).remove();
}
}).insertBefore($(this));
$("#" + new_ele_id).focus();
});
//remove element script
$(".remove_this").on('click', function () {
if ($(this).is(":visible") == true) {
if (confirm("Are you sure?")) {
$("#" + $(this).attr("data-target-id")).remove();
$(this).remove();
}
}
else {
$("#" + $(this).attr("data-target-id")).remove();
$(this).remove();
}
});
Usage: Single Element http://jsfiddle.net/vkscorpion1986/ktbn4qLg/2/
<input class="" id="<ELEMENT-ID>" type="text" name="input1">
Add More
Usage: Grouped Elements http://jsfiddle.net/vkscorpion1986/ktbn4qLg/4/
<div id="<ELEMENT-ID>">
<input class="" id="input1" type="text" name="input1">
<input class="" id="input2" type="text" name="input2">
</div>
Add More
attributes
href = javascript:void(0); // just to disable the anchor tag default behaviour
data-clone-target = id of the target element
css classes
.add_more = to implement the add more/remove controls functionality
.group_control = for indicating that this is group of elements which have to be repeted
Hope this works for you.
No, it's not made with jTable. You can use input option (http://jtable.org/ApiReference#fopt-input) and this: http://jqueryui.com/autocomplete/#multiple Or you can create your own dialog.
Does anyone have an example of sending a geolocation from a mobile phone to a JSF backing bean?
Would like to get the customers address using geolocation? (Will need to convert from geolocation co-ordinates to a drop down list of nearby roads).
Thanks,
D
Not sure if this will help u get started...
This pulls GPS Geolocation Data from Mobile Devices into a Form...
Then do whatever with it from there...
<script type="text/javascript">
function getLocationConstant()
{
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(onGeoSuccess,onGeoError);
} else {
alert("Your browser or device doesn't support Geolocation");
}
}
// If we have a successful location update
function onGeoSuccess(event)
{
document.getElementById("Latitude").value = event.coords.latitude;
document.getElementById("Longitude").value = event.coords.longitude;
}
// If something has gone wrong with the geolocation request
function onGeoError(event)
{
alert("Error code " + event.code + ". " + event.message);
}
</script>
<cfform action="gps2.cfm" method="post">
Latitude: <input type="text" id="Latitude" name="Latitude" value="">
<br><br>
Longitude: <input type="text" id="Longitude" name="Longitude" value="">
<br><br>
<input type="button" value="Get Location" onclick="getLocationConstant()"/>
<br><br>
<input type="submit" value="Add GPS Location" class=small>
</cfform>
View this links please:
https://developers.google.com/maps/documentation/javascript/examples/map-geolocation - Google Developers
https://goo.gl/TD7aiq - JsFiddle
JS:
// Note: This example requires that you consent to location sharing when
// prompted by your browser. If you see the error "The Geolocation service
// failed.", it means you probably did not give permission for the browser to
// locate you.
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 6
});
var infoWindow = new google.maps.InfoWindow({map: map});
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infoWindow.setPosition(pos);
infoWindow.setContent('Location found.');
map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
}
Using the Javascript you can get the co-ordinates and you can set the backend variable using document.getElementById("id")) in javascript.
Example:
<h:inputText value="{myBean.latitude}" id="latitudeID" />
<!DOCTYPE html>
<html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
document.getElementById("formName:latitudeID").value=position.coords.latitude; /* this will set the value in variable */
}
</script>
</body>
</html>