Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-11-12 02:01:40
Point:500 Replies:19 POST_ID:828419USER_ID:11059
Topic:
Hypertext Markup Language (HTML);;JavaScript
Just want to how to dectect enter key after users input product No: in inputbox.
When users press enter key, the URL will redirect to other link accroding to inputbox
product NO and display page in second frame in the same window of inputbox.
After redirection is completed, the inputbox will be clear for users to be ready
for next edit product No:. So the question, how to write a code for onkeydown to
dectect enter key and do clear inputbox value for user next edit ?
THe following javascript code is finished inputbox, frame set for URL redirect, onclick clear vlaue operation but except final one for detecting enter key to clear input box vlaue for next product
NO edit
Please advise
Ducan
When users press enter key, the URL will redirect to other link accroding to inputbox
product NO and display page in second frame in the same window of inputbox.
After redirection is completed, the inputbox will be clear for users to be ready
for next edit product No:. So the question, how to write a code for onkeydown to
dectect enter key and do clear inputbox value for user next edit ?
THe following javascript code is finished inputbox, frame set for URL redirect, onclick clear vlaue operation but except final one for detecting enter key to clear input box vlaue for next product
NO edit
Please advise
Ducan
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Testing Input Box</title><TITLE>Document Title</TITLE><script>function formSubmit(frm){ document.getElementById("frame1").src="http://www.mywebsite.com/"+frm.text1.value+".htm";onkeydown="if (event.keyCode==13) {frm.text1.value=''}" return false;}</script></HEAD><body><style>.highlighted { background-color:white; }</style><form onsubmit="return formSubmit(this)"><input type="text" name="text1" value="0000" onclick="this.value=''; this.className='highlighted'" onblur="if(this.value=='')this.value=this.defaultValue; this.className=''" /><input type="submit" name="submit" ></form><iframe height="700" width="1400" scrolling="no" border="0px" id="frame1" src="http://www.mywebsite.com/index.htm"></body> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:
Author: duncanb7 replied at 2024-11-12 17:14:20
Yes, your are right, I also
put el.value='' that is also working
if (key==13){
fn();
el.value='";
return false;
put el.value='' that is also working
if (key==13){
fn();
el.value='";
return false;
Expert: SouthMod replied at 2024-11-12 15:20:32
Per author request (http://www.experts-exchange.com/Q_26610487.html) I've reopened this thread. The comment accepted originally was: #a34119549
SouthMod
EE Moderator
SouthMod
EE Moderator
Author: duncanb7 replied at 2024-11-12 08:58:28
Dear TiberiuGal,
Could you comment this new thread at
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26611155.html ?
please advise
Duncan
Could you comment this new thread at
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26611155.html ?
please advise
Duncan
Author: duncanb7 replied at 2024-11-12 04:29:28
Yes, your are right, I also
put el.value='' that is also working
if (key==13){
fn();
el.value='";
return false;
put el.value='' that is also working
if (key==13){
fn();
el.value='";
return false;
Accepted Solution
Expert: TiberiuGal replied at 2024-11-12 04:16:35
500 points EXCELLENT
I missed that part :
function formSubmit() { var my_val = document.getElementById('text1').value; // check if value is empty if ( my_val.length > 0) { document.getElementById("frame1").src="http://www.mywebsite.com/"+ my_val +".htm"; } document.getElementById('text1').value = '';} 1:2:3:4:5:6:7:8:9:10:
Author: duncanb7 replied at 2024-11-12 04:16:33
I mean after enter key is pressed,
formSubmit() function activate first or do first for redirect, and then check enter key operation is next
to clear input box so user doesn't need to click the input box again for next edit
formSubmit() function activate first or do first for redirect, and then check enter key operation is next
to clear input box so user doesn't need to click the input box again for next edit
Author: duncanb7 replied at 2024-11-12 04:14:51
Actually you understand my question ?
Do i need to write it again
Do i need to write it again
Author: duncanb7 replied at 2024-11-12 04:12:12
Okay it is back to previous thread status, for example,
Edit 66666 and Press enter ,and redirect it is sucessful t0 .../66666.htm but
66666 number is still in input box not clear so user needs to click again for next edit.
So, the checkenter is not done yet , Please advise
Edit 66666 and Press enter ,and redirect it is sucessful t0 .../66666.htm but
66666 number is still in input box not clear so user needs to click again for next edit.
So, the checkenter is not done yet , Please advise
Expert: TiberiuGal replied at 2024-11-12 03:59:56
Hi,
I see, the function formSubmit references the form, we need to change that reference by adding an id attribute to the text box
I see, the function formSubmit references the form, we need to change that reference by adding an id attribute to the text box
function formSubmit() { var my_val = document.getElementById('text1').value; // check if value is empty if ( my_val.length > 0) { document.getElementById("frame1").src="http://www.mywebsite.com/"+ my_val +".htm"; }}<input type="text" name="text1" id="text1" ... 1:2:3:4:5:6:7:8:9:10:11:
Author: duncanb7 replied at 2024-11-12 03:57:51
onkeydown="return checkEnter(event, this, formSubmit);" />
to be repacled by onkeydown="return checkEnter(event, this, formSubmit() );" />
Is it correct ?
to be repacled by onkeydown="return checkEnter(event, this, formSubmit() );" />
Is it correct ?
Author: duncanb7 replied at 2024-11-12 03:56:20
Dear TiberiuGal,
When delete <form onsubmit="return formSubmit(this)"> and then
redirect to www.mywbeiste.com/66666.htm is failed. it is getting worse
than the previous thread
Please advise.
Duncan
When delete <form onsubmit="return formSubmit(this)"> and then
redirect to www.mywbeiste.com/66666.htm is failed. it is getting worse
than the previous thread
Please advise.
Duncan
Author: duncanb7 replied at 2024-11-12 03:44:25
http://www.experts-exchange.com/Community_Support/General/Q_26610487.html
Sorry again, I already submit re-credit form to EE adm
Sorry again, I already submit re-credit form to EE adm
Author: duncanb7 replied at 2024-11-12 03:40:45
Sorry the point is going to expert, TiberiuGal, and I will re-credit in since I score it too fast
Expert: Bardobrave replied at 2024-11-12 03:37:18
onKeyDown fires everytime a user press a key within the focused object.
If I understand what you want, you only need to make a function that fires on product number keyDown where you recover the value on product number input, change the action of your form according to this readed value when keyCode pressed is 13 and finally submits the form.
If I understand what you want, you only need to make a function that fires on product number keyDown where you recover the value on product number input, change the action of your form according to this readed value when keyCode pressed is 13 and finally submits the form.
Expert: TiberiuGal replied at 2024-11-12 03:34:51
<script type="text/javascript">// e - event, el - element, fn- callback functionfunction checkEnter(e, el, fn) { var key=e.keyCode || e.which; if (key==13){ fn(); return false; } return true;}function formSubmit() { var my_val = frm.text1.value; // check if value is empty if ( my_val.length > 0) { document.getElementById("frame1").src="http://www.mywebsite.com/"+ my_val +".htm"; }}</script><!-- there's no need of a form if you handle it via an iframe --><input type="text" ...onkeydown="return checkEnter(event, this, formSubmit);" /><input type="button" value="submit" onclick="formSubmit();" /> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:
Expert: TiberiuGal replied at 2024-11-12 03:29:55
Fix:
Expert: TiberiuGal replied at 2024-11-12 03:28:12
Hi,
you can use onkeydown without a problem. But the formSubmit function doesn't make sense to me.
here's how I'd write it
you can use onkeydown without a problem. But the formSubmit function doesn't make sense to me.
here's how I'd write it
<script type="text/javascript">// e - event, el - element, fn- callback functionfunction checkEnter(e, el) { var key=e.keyCode || e.which; if (key==13){ fn(); return false; } return true;}function formSubmit() { document.getElementById("frame1").src="http://www.mywebsite.com/"+ frm.text1.value +".htm";}</script><!-- there's no need of a form if you handle it via an iframe --><input type="text" ...onkeydown="return checkEnter(event, this, formSubmit);" /><input type="button" value="submit" onclick="formSubmit();" /> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:
Author: duncanb7 replied at 2024-11-12 03:06:58
I think I could not use onkeydown because there is onclick and onsubmit operation, and I need those two
operation is finished and detecting last key of enter key, so I should put detecting ocde in the function
formSubmit(frm), Right ? but the following code is not working because I don't know what is the event
function formSubmit(frm)
{
document.getElementById("frame1").src="http://www.mywebsite.com/"+frm.text1.value+".htm";
if (event.keyCode==13) {frm.text1.value=''};
return false;
}
operation is finished and detecting last key of enter key, so I should put detecting ocde in the function
formSubmit(frm), Right ? but the following code is not working because I don't know what is the event
function formSubmit(frm)
{
document.getElementById("frame1").src="http://www.mywebsite.com/"+frm.text1.value+".htm";
if (event.keyCode==13) {frm.text1.value=''};
return false;
}
Expert: Bardobrave replied at 2024-11-12 02:48:58
Take a look at this:
http://www.w3schools.com/jsref/event_onkeydown.asp
The keyCode for Intro if I remember well is 13
http://www.w3schools.com/jsref/event_onkeydown.asp
The keyCode for Intro if I remember well is 13