Is it possible to get mouse buttons 4, 5, etc? - javascript

Simply put, is there any way to detect additional mouse button presses in JavaScript? It's not documented with the rest of the mouse input, so I guess it's not in standard implementation.
Is there any way, such as a library, which can enable extra mouse buttons?

Yes you could do this, check MouseEvent.button, see example below that will detect 3 and 4 buttons click.
Some pointing devices provide or simulate more buttons. To represent such buttons, the value must be doubled for each successive button (in the binary series 8, 16, 32, ... ) as mentioned in https://www.w3.org/TR/DOM-Level-3-Events/#events-mouseevents
var whichButton = function (e) {
// Handle different event models
var e = e || window.event;
var btnCode;
if ('object' === typeof e) {
btnCode = e.button;
switch (btnCode) {
case 3:
console.log('Browser Back button clicked.');
break;
case 4:
console.log('Browser Forward button clicked.');
break;
default:
console.log('Unexpected code: ' + btnCode);
}
}
}
<button onmouseup="whichButton(event);" oncontextmenu="event.preventDefault();">Click with mouse...</button>

var whichButton = function (e) {
// Handle different event models
var e = e || window.event;
var btnCode;
if ('object' === typeof e) {
btnCode = e.button;
switch (btnCode) {
case 3:
console.log();
break;
case 4:
console.log();
break;
default:
console.log('Unexpected code: ' + btnCode);
}
}
}

Related

how to event more keys within javascript

I want to eventing more keys in my Javascript code:
<script>
function OPEN(e) {
if (e.type !== "blur") {
if (e.keyCode === 70) {
alert("Pressed F");
}
}
}
document.onkeydown = OPEN;
</script>
What I am getting from your question is that you want to detect more keys presses. The best way to detect key presses is a switch statement
function OPEN(e) {
if (e.type !== "blur") {
switch (e.keyCode) {
case 70:
alert("Pressed F");
break;
case 65:
alert("Pressed A");
break;
default:
alert("I don't know what to do with that key!");//This line is removable
break;
}
}
}
document.onkeydown = OPEN;
How it works
The way a switch works is:
switch (VALUE) {
case THIS_VALUE:
CODE
break;
default:
CODE
break;
}
That was probably the worst explanation you've seen so you can read about here
Without keyCode
keyCodes are kind of irritating to figure out, you can use:
function OPEN(e) {
if (e.type !== "blur") {
switch (String.fromCharCode(e.keyCode)) {
case "F":
alert("Pressed F");
break;
case "A":
alert("Pressed A");
break;
case "B":
alert("Pressed B");
default:
alert("I don't know what to do with that key!");//This line is removable
break;
}
}
}
document.onkeydown = OPEN;
Detect Key Combinations
When detecting key combinations, you can use && to make sure both key's are pressed. Without some more complicated. You can use:
e.metaKey Window key on Windows, Command Key on Mac
e.ctrlKey Control key
e.shiftKey Shift key
e.altKey Alt key
Use them as:
if (e.ctrlKey && e.keyCode === 65) {
alert("Control and A key pressed");
}
To detect all keys are currently pressed (multiple) I found this fiddle (not mine), and a question here
may be that make what you want
<script>
function OPEN(event) {
var x = event.which || event.keyCode;
alert( "The Unicode value is: " + String.fromCharCode(x));
// The Unicode value is: a
//The Unicode value is: b
}
</script>
then add this attr to your body
<body onkeydown="OPEN(event)">
If you're not opposed to using a library for this, I find Mousetrap.js to be awesome and very easy to use.
Here are a few examples from the link above:
<script>
// single keys
Mousetrap.bind('4', function() { console.log('4'); });
Mousetrap.bind("?", function() { console.log('show shortcuts!'); });
Mousetrap.bind('esc', function() { console.log('escape'); }, 'keyup');
// combinations
Mousetrap.bind('command+shift+k', function() { console.log('command shift k'); });
// map multiple combinations to the same callback
Mousetrap.bind(['command+k', 'ctrl+k'], function() {
console.log('command k or control k');
// return false to prevent default browser behavior
// and stop event from bubbling
return false;
});
// gmail style sequences
Mousetrap.bind('g i', function() { console.log('go to inbox'); });
Mousetrap.bind('* a', function() { console.log('select all'); });
// konami code!
Mousetrap.bind('up up down down left right left right b a enter', function() {
console.log('konami code');
});
</script>

How to intercept the various button press of a mouse using JavaScript?

The web application I work on was designed and developed during the period where there existed only 2-button mice. Now that we have more than 3-button mice available in the market, all those extra buttons are causing havoc while using our application.
My intention is to allow the user to press only the left mouse button and disable all other buttons on his mice. Since, I do not have access to the user's system, I have to achieve this somehow through the browser itself (probably by using JavaScript).
How can I go about solving this problem? Any pointers would be really helpful.
W3C event model is kind enough to pass mouse information through the event object. That means you can actually read which mouse button was clicked. Example
document.body.addEventListener('click', function( event ) {
console.log('mouse button clicked: ', event.which);
}, false);
With that information its fairly trivial to only allow left-clicks, which are represented by the value 1.
document.body.addEventListener('click', function( event ) {
if( event.which === 1 ) {
// do something
} else {
event.stopPropagation();
event.preventDefault();
}
}, false);
It depends on the browser and document mode.
This is how we tweaked prototype.js buttonmaps to work on all browsers. Including IE10 in docmode < 9.
function _isButtonForDOMEvents(event, code) {
return event.which ? (event.which === code + 1) : (event.button === code);
}
//var legacyButtonMap = { 0: 1, 1: 4, 2: 2 };
function _isButtonForLegacyEvents(event, code) {
switch (code) { //Fix where IE10 in DocMode lt9 caused isLeftClick to fail
case 0: return event.button == 0 || event.button == 1;
case 1: return event.button == 4;
case 2: return event.button == 2;
default: return false;
}
}
function _isButtonForWebKit(event, code) {
switch (code) {
case 0: return event.which == 1 && !event.metaKey;
case 1: return event.which == 2 || (event.which == 1 && event.metaKey);
case 2: return event.which == 3;
default: return false;
}
}
I think this is the closest you will get to disabling the buttons
document.addEventListener('click', function( e ){
if(e.which === 2 || e.which === 3) { // 2 = middle scroll button || 3 = right click
e.preventDefault();
e.stopPropagation();
return false;
}
});
Instead of click if it doesn't work you can try 'keydown' or 'keyup'

How to get the focus of the elements in javascript using keyarrows

My html contains list of elements. I want to use the arrow keys to select the elements.
Here is my Code: [http://jsfiddle.net/T8S7c/]
What I want is on preesing the keys the focus needs to be in the selected element like hover effects.( For example if I press the down key for the first time Ambaji has to be in focus)
I know the code of the key event but i dont know how to get the focus on the keypress.
Can anyone help me in this
My strategy for solving this would be to specify an order of focus through an array of the links, as well as having some variable specifying which link should be in focus.
var order = new Array("l1", "l2", "l3", "l4");
var current = -1;
function updateCurrent(inc) {
current = (current + inc) % order.length;
current = Math.max(current, 0);
}
document.onkeydown = function(evt) {
evt = evt || window.event;
switch (evt.keyCode) {
case 38:
updateCurrent(-1);
document.getElementById(order[current]).focus();
break;
case 40:
updateCurrent(1);
document.getElementById(order[current]).focus();
}
};
Updated your script. Have a look at this. Fiddle : http://jsfiddle.net/T8S7c/6/
var myLinks = document.getElementsByTagName("a");
var myLinksIndex = 0;
myLinks[myLinksIndex].focus();
document.onkeydown = function(evt) {
evt = evt || window.event;
switch (evt.keyCode) {
case 38: // Up arrow
if(myLinksIndex > 0){myLinks[-- myLinksIndex].focus();}
break;
case 40:// Down arrow
if(myLinksIndex < myLinks.length){myLinks[++ myLinksIndex].focus();}
break;
}
};

Selenium testing - events seem not to be fired

I'm using embedded glassfish to deploy my web application and test it with arquillian remote control. While everything's been going nice so far, we found a problem when trying to deal with a suggestions feature in the application. It basically consists of a text box which offers a list of possibly matching items once 3 or more characters have been typed.
<div class="uiModuleSelectingConcepts suggestion_${cc.id}">
<div class="searchBox">
<fieldset>
<input type="text"
class="sample"
value="${cc.attrs.input_label}"
placeholder="${cc.attrs.input_label}"/>
<i></i>
</fieldset>
</div>
<a4j:outputPanel id="suggestion_component_container"
styleClass="suggestionsWrapper"
layout="block">
<div class="suggestionsList_${cc.id}">
</div>
</a4j:outputPanel>
</div>
Some events are added so these suggestions are properly displayed, as follows (in the following code, the parameter inputNode) is the textbox itself where the user types...there is where we add the events):
this.addEventHandlers = function (inputNode, suggestionCallback, params) {
var parent = this;
inputNode
/*
* keypress event.
*/
.keypress(function(event) {
if (event.keyCode === 13) {
event.preventDefault();
}
})
/*
* keyup event.
*/
.keyup(function(event) {
switch (event.keyCode) {
/**
* Up arrow.
*/
case 38:
event.stopPropagation();
event.preventDefault();
var suggestionsWrapper = parent._params.list;
var currentSelectedValue = null;
if (suggestionsWrapper.find(".suggestionItem").length) {
if (suggestionsWrapper.find(".suggestionItem:first").hasClass("focused")) {
suggestionsWrapper.find(".focused").removeClass("focused");
suggestionsWrapper.find(".suggestionItem:last").addClass("focused");
//currentSelectedValue = suggestionsWrapper.find(".suggestionItem:last").val();
} else {
suggestionsWrapper.find(".focused").removeClass("focused").prev().addClass("focused");
};
//set the selected value to input.
//console.debug("Current Valiue", suggestionsWrapper.find(".focused"));
var e = suggestionsWrapper.find(".focused");
if (e.length > 0) {
//console.debug("Current e", e);
currentSelectedValue = typeof e === 'undefined' ? null : e.attr('data-suggest');
//console.debug("Current Valiue", currentSelectedValue);
if (currentSelectedValue != null) {
jQuery(this).val(Encoder.htmlDecode(currentSelectedValue));
}
}
}
parent._blur = false;
break;
/**
* Down arrow.
*/
case 40:
var suggestionsWrapper = parent._params.list;
var currentSelectedValue = null;
if (suggestionsWrapper.find(".suggestionItem").length) {
if (suggestionsWrapper.find(
".suggestionItem:last").hasClass("focused")) {
suggestionsWrapper.find(".focused").removeClass("focused");
suggestionsWrapper.find(".suggestionItem:first").addClass("focused");
} else {
suggestionsWrapper.find(".focused").removeClass("focused").next().addClass("focused");
};
//console.debug("Current Valiue", suggestionsWrapper.find(".focused"));
var e = suggestionsWrapper.find(".focused");
//console.debug("Current e", e);
if (e.length > 0) {
currentSelectedValue = typeof e === 'undefined' ? null : e.attr('data-suggest');
//console.debug("Current Valiue", currentSelectedValue);
if (currentSelectedValue != null) {
jQuery(this).val(Encoder.htmlDecode(currentSelectedValue));
}
}
}
parent._blur = false;
break;
/**
* ENTER key
*/
case 13:
event.stopPropagation();
event.preventDefault();
var suggestionsWrapper = parent._params.list;
var oConcept = suggestionsWrapper.find(".focused");
if (typeof oConcept !== "undefined") {
oConcept.trigger("click");
}
parent._blur = true;
parent._cleanSuggestions();
jQuery(this).blur();
break;
/**
* ESC key event.
*/
case 27:
event.stopPropagation();
event.preventDefault();
var sValue = jQuery(this).attr("data-default");
sValue = jQuery.trim(sValue);
if (sValue === jQuery(this).attr("data-default")) {
jQuery(this).addClass("sample").blur();
}
parent._blur = true;
parent._cleanSuggestions();
jQuery(this).val("");
jQuery(this).blur();
break;
default:
var suggestionsWrapper = parent._params.list;
//var typeRight = jQuery(this).parents(".tabContent").attr("id");
var sValue = jQuery.trim(jQuery(this).val());
//var oThisInput = jQuery(this);
if (sValue.length > MEDIA.configuration.SUGGESTION_LIMIT) {
suggestionsWrapper.find(".suggestionItem").remove();
global.uiDelay( function() {
parent.displayLoading();
suggestionCallback(sValue, MEDIA.util.getTrueFalseValue(parent._params.retrieveOnlyClasses) ? suggestOnlyConcepts : "");
}, 1000);
} else {
parent.writeMore();
}
parent._blur = true;
break;
};
}).keydown(function(event) {
switch (event.keyCode) {
case 38: // up
event.stopPropagation();
event.preventDefault();
break;
case 40: // down
event.stopPropagation();
event.preventDefault();
break;
default:
break;
};
}).focus(function() {
jQuery(this).val("");
parent._blur = true;
// when suggestions lose focus
}).blur(function() {
if (parent._blur) {
jQuery(this).val("");
parent._cleanSuggestions();
}
});
};
When the application is deployed normally (for no testing purposes, without selenium) it works as expected and when typing something the suggestions are displayed. However, when using Selenium no matter what is typed in the box nothing happens. We've tried many possibilities and combinations with .keyDown(), .keyPress(), .keyUp() with their char, keyCode and native variants. Also, .type(), .typeKeys()....all of them to no avail. It would seem as though for some reasons the events are ignored (the funny thing is, if we hand-type some text in the browser selenium opens for testing the application, the suggestions -do- display. They only don't when it's selenium doing the typing).
Any help would be greatly appreciated. Not sure if I made complete sense, we'd be happy to clarify.
Greetings.
I used this simple testpage and jQuery 1.7.2 (the input to the first field should get copied into the another):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
</head>
<body>
<input type="text" id="myInput" />
<input type="text" id="yourInput" />
<script>
$("#myInput").keyup(function(event) {
$("#yourInput").val(this.value);
});
</script>
</body>
</html>
Let me state the annoying truth right in the beginning: With WebDriver, everything works well and smoothly.
WebDriver driver = new InternetExplorerDriver();
driver.get("the path to the file");
driver.findElement(By.id("myInput")).sendKeys("Hello.");
driver.quit();
Anyway, what I was able to make it work in Selenium RC, too:
sele.focus("id=myInput");
sele.keyPressNative(String.valueOf(KeyEvent.VK_H));
sele.keyPressNative(String.valueOf(KeyEvent.VK_E));
sele.keyPressNative(String.valueOf(KeyEvent.VK_L));
sele.keyPressNative(String.valueOf(KeyEvent.VK_L));
sele.keyPressNative(String.valueOf(KeyEvent.VK_O));
It kind of sucks, but it's the best I came up with where the event works.

JavaScript force an OnChange in Maximo

I'm currently working on a Bookmarklet for Maximo, which is a Java EE application, and I need to populate a few input boxes.
Generally when a use inputs data into the box they click a button that gives them a popup and they search for the value to be added to the script. Or they can type the name and hit tab/enter and it turns it to capital letters and does a few things in the background (not sure what it does exactly).
I currently use
Javascript: $('mx1354').value = "KHBRARR"; $('mx1354').ov= "KHBRARR";
But it does not work like I need it to. It set's the input box to the value needed, but it doesn't run the background functions so when I hit the save button it doesn't recognize it as any changes and discards what I put into the box.
How could I simulate a tab/enter button has been pressed?
So far I've tried to call the onchange, focus/blur, and click functions (Not 100% sure if I called them correctly).
The dojo library is part of the application, so I'm not sure if I can use one if it's feature or if jQuery would cause a conflict.
P.S. This needs to run in IE.
The OnChange Function:
function tb_(event)
{
event = (event) ? event : ((window.event) ? window.event : "");
if(DESIGNMODE)
return;
var ro = this.readOnly;
var exc=(this.getAttribute("exc")=="1");
switch(event.type)
{
case "mousedown":
if(getFocusId()==this.id)
this.setAttribute("stoptcclick","true");
break;
case "mouseup":
if (isIE() && !hasFocus(this))
{
this.focus();
}
if (isBidiEnabled)
{
adjustCaret(event, this); // bidi-hcg-AS
}
break;
case "blur":
input_onblur(event,this);
if (isBidiEnabled) // bidi-hcg-SC
input_bidi_onblur(event, this);
break;
case "change":
if(!ro)
input_changed(event,this);
break;
case "click":
if(overError(event,this))
showFieldError(event,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")
{
event.cancelBubble=true;
}
this.setAttribute("stoptcclick","false");
break;
case "focus":
input_onfocus(event,this);
if (isBidiEnabled) // bidi-hcg-SC
input_bidi_onfocus(event, this);
this.select();
break;
case "keydown":
this.setAttribute("keydown","true");
if(!ro)
{
if(isBidiEnabled)
processBackspaceDelete(event,this); // bidi-hcg-AS
if(hasKeyCode(event, 'KEYCODE_DELETE') || hasKeyCode(event, 'KEYCODE_BACKSPACE'))
{
getHiddenForm().elements.namedItem("changedcomponentvalue").value = this.value;
}
if((hasKeyCode(event, 'KEYCODE_TAB') || hasKeyCode(event, '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(event, 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(event, 'KEYCODE_ESC'))
{
if (event.preventDefault)
{
event.preventDefault();
}
else
{
event.returnValue = false;
}
return;
}
}
}
}
input_keydown(event,this);
datespin(event,this);
}
else if(hasKeyCode(event,'KEYCODE_ENTER') || (hasKeyCode(event,'KEYCODE_DOWN_ARROW') && this.getAttribute("liclick")))
{
var lbId = this.getAttribute("li");
frontEndEvent(getElement(lbId), 'click');
}
else if(hasKeyCode(event,KEYCODE_BACKSPACE))
{
event.cancelBubble=true;
event.returnValue=false;
}
break;
case "keypress":
if(!ro)
{
if(event.ctrlKey==false && hasKeyCode(event,'KEYCODE_ENTER'))
{
var db = this.getAttribute("db");
if(db!="")
{
sendClick(db);
}
}
}
break;
case "keyup":
var keyDown = this.getAttribute("keydown");
this.setAttribute("keydown","false");
if(event.ctrlKey && hasKeyCode(event,'KEYCODE_SPACEBAR'))
{
if(showFieldError(event,this,true))
{
return;
}
else
{
menus.typeAhead(this,0);
}
}
if(!ro)
{
if(isBidiEnabled)
processBidiKeys(event,this); // bidi-hcg-AS
numericcheck(event,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(event.ctrlKey==false && hasKeyCode(event,'KEYCODE_ENTER'))
{
var db = this.getAttribute("db");
if(db!="")
{
defaultButton=true;
}
}
input_changed(event,this);
}
else
{
setFocusId(event,this);
}
if(showFieldHelp(event, this))
{
return;
}
if(keyDown=="true" && hasKeyCode(event, 'KEYCODE_ENTER') && !event.ctrlKey && !event.altKey)
{
menus.typeAhead(this,0);
return;
}
if(!hasKeyCode(event, 'KEYCODE_ENTER|KEYCODE_SHIFT|KEYCODE_CTRL|KEYCODE_ESC|KEYCODE_ALT|KEYCODE_TAB|KEYCODE_END|KEYCODE_HOME|KEYCODE_RIGHT_ARROW|KEYCODE_LEFT_ARROW')
&& !event.ctrlKey && !event.altKey)
{
menus.typeAhead(this,0);
}
break;
case "mousemove":
overError(event,this);
break;
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;
}
}
After some time I found that in order to make a change to the page via JavaScript you need to submit a hidden form so it can verify on the back-end.
Here is the code I used to change the value of Input fields.
cc : function(e,v){
e.focus(); //Get focus of the element
e.value = v; //Change the value
e.onchange(); //Call the onchange event
e.blur(); //Unfocus the element
console.log("TITLE === "+e.title);
if(e.title.indexOf(v) != -1) {
return true; //The value partially matches the requested value. No need to update
} else {
//Generate an hidden form and submit it to update the page with the new value
var hiddenForm = getHiddenForm();
var inputs = hiddenForm.elements;
inputs.namedItem("changedcomponentid").value = e.id;
inputs.namedItem("changedcomponentvalue").value = v;
inputs.namedItem("event").value = "X"; //Send a Dummy Event so the script see's its invalid and sets the right Event
submitHidden();
}
//Value isn't set to the required value so pass false
return false;
}
run this
input_changed(null,document.getElementById('IDHERE'));
In maximo 7.5 i built a custom lookup
when i click the colored hyperlink java script is called to update the values back to parent form values or updated but on save the value or not updated
function riskmatrix_setvalue(callerId, lookupId, value,bgrColor,targetid){
if (document.getElementById(callerId).readOnly){
sendEvent('selectrecord', lookupId);
return;
}
textBoxCaller = document.getElementById(callerId);
//dojo.byId(callerId).setAttribute("value", value);
//dojo.byId(callerId).setAttribute("changed", true);
//dojohelper.input_changed_value(dojo.byId(callerId),value);
//textBoxCaller.style.background = bgrColor;
//var hiddenForm = getHiddenForm();
//if(!hiddenForm)
// return;
//var inputs = hiddenForm.elements;
//inputs.namedItem("event").value = "setvalue";
//inputs.namedItem("targetid").value = dojo.byId(callerId).id;
//inputs.namedItem("value").value = value;
//sendXHRFromHiddenForm();
textBoxCaller.focus(); //Get focus of the element
textBoxCaller.value = value; //Change the value
textBoxCaller.onchange(); //Call the onchange event
textBoxCaller.blur(); //Unfocus the element
//Generate an hidden form and submit it to update the page with the new value
var hiddenForm = getHiddenForm();
var inputs = hiddenForm.elements;
inputs.namedItem("changedcomponentid").value = textBoxCaller.id;
inputs.namedItem("changedcomponentvalue").value = value;
inputs.namedItem("event").value = "X"; //Send a Dummy Event so the script see's its invalid and sets the right Event
submitHidden();
sendEvent("dialogclose",lookupId);
}
Description
I changed a bit #Steven10172's perfect solution and made it into a Javascript re-usable function.
Made this into a separate answer since my edits to the original answer where i added this were refused :)
I also had to change the line e.onchange() to e.onchange(e) because otherwise the textbox handler (tb_(eventOrComponent) function) would throw TypeError: textbox.getAttribute is not a function.
Code
var setFakeValue = function(e,v){
console.log("Changing value for element:", e, "\nNew value:", v);
e.focus(); //Get focus of the element
e.value = v; //Change the value
e.onchange(e); //Call the onchange event
e.blur(); //Unfocus the element
if(e.title.indexOf(v) != -1) {
return true; //The value partially matches the requested value. No need to update
}
else {
//Generate an hidden form and submit it to update the page with the new value
var hiddenForm = getHiddenForm();
var inputs = hiddenForm.elements;
inputs.namedItem("changedcomponentid").value = e.id;
inputs.namedItem("changedcomponentvalue").value = v;
inputs.namedItem("event").value = "X"; //Send a Dummy Event so the script see's its invalid and sets the right Event
submitHidden();
}
//Value isn't set to the required value so pass false
return false;
}
Usage
setFakeValue(html_element, new_value);
Fun fact
I spent a lot of time searching for a solution to programmatically change an <input> value in Maximo... At some point i got really frustrated, gave up and started to think it just wasn't possible...
Some time ago i tried to search with no expectations at all and after some time i found the solution... Here...
Now... As you can see this is literally just a total copy of StackOverflow, including questions and solutions (marking the upvotes with plain text lol), but in Chinese... This got me curious and after a little search i found this post on StackOverflow..
High five to Chrome built-in webpage translator that let understand something on that page ^^

Categories

Resources