shaffiq_fiq88
-
Posts
37 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by shaffiq_fiq88
-
-
I want to capture keypress event while passing other value in function. I've already and still googling but still not found the answer.Here is the coding :
function inputkeyup(i){if (event.keyCode!==13){// do something like thisalert(i.value)};};<input name="myipt" type="text" id="myipt" size="15" maxlength="12" onKeyUp="inputkeyup(this)"><input name="myipt2" type="text" id="myipt2" size="15" maxlength="12" onKeyUp="inputkeyup(this)">
Latest Firefox console tell "ReferenceError: event is not defined" and the code is not functioning
How to make it working?
No jQuery please because I will learn nothing.
Thanks for any help.
-
Success . Thanks so much JamesB.you need quotes around n in the callback parameter:'.. onkeypress="keyE(event,\'' + n + '\',this.value)" />';
-
function keyE(e,n,v) {// some function here}; function editProp(n) {// the caller is a button with function onClick="editProp('userID')"// n = 'userID'var dStr = document.getElementById(n).innerHTML;document.getElementById('f_' + n).innerHTML = '<input type="text" name="i_' + n + '" id="i_userID" value="' + dStr+ '" onkeypress="keyE(event,' + n + ',this.value)" />'; //error heredocument.getElementById('i_' + n).focus();document.getElementById('i_' + n).setSelectionRange(0,dStr.length);} // debug with Mozilla Firefox 15.0.1 Developer Tools
The editProp(n) function generate error and I don't know how to fix it. The error is at document.getElementById('f_' + n).innerHTML = '<input type="text" name="i_' + n + '" id="i_userID" value="' + dStr+ '" onkeypress="keyE(event,' + n + ',this.value)" />'; The phrase onkeypress="keyE(event,' + n + ',this.value)" generate error "userID is not defined". userID is a string defined in n variable but it detect it as a variable. How to fix it? Thanks for any help provided.
How to Trigger Event of Other Elements?
in JavaScript
Posted · Edited by Fiq
I want background image of 'section-spg-img' changed as 'sectionseparator:hover' when I hover mouse in any region within 'section-spg'. I've searching and try every event method. Either I'm stupid enough and failed or I'm not understand anything about event.
Image sprite contain {+,hovered +, -, hovered -}.
showHideInfo() change either + or - of the image and show or hide 'spg-info'. (success)
imgHover() change either hovered + or hovered - of the image. (failed)
Example : http://www.microsoft.com/en-us/download/details.aspx?id=30653 (Detail, System Requirement, etc...)
I don't wanna use jQuery.
Thank you.