HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 1st, 2008, 09:57 PM
lovesirius12 lovesirius12 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 10 lovesirius12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 24 m 41 sec
Reputation Power: 0
General - Question - Key Down on TextBox

this is using Classic ASP

how can i put an onkeydown event on the textbox wherein the action would be the same as clicking the button next to it.

any help is highly appreciated. thanks.

Reply With Quote
  #2  
Old May 2nd, 2008, 12:33 AM
Dr_Rock's Avatar
Dr_Rock Dr_Rock is offline
Wizard Down Under
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Location: Australia
Posts: 197 Dr_Rock User rank is First Lieutenant (10000 - 20000 Reputation Level)Dr_Rock User rank is First Lieutenant (10000 - 20000 Reputation Level)Dr_Rock User rank is First Lieutenant (10000 - 20000 Reputation Level)Dr_Rock User rank is First Lieutenant (10000 - 20000 Reputation Level)Dr_Rock User rank is First Lieutenant (10000 - 20000 Reputation Level)Dr_Rock User rank is First Lieutenant (10000 - 20000 Reputation Level)Dr_Rock User rank is First Lieutenant (10000 - 20000 Reputation Level)Dr_Rock User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 15 h 25 m 7 sec
Reputation Power: 159
Send a message via MSN to Dr_Rock Send a message via Yahoo to Dr_Rock
You cant do it in asp as it is a client side function, you will need to use javascript"

Code:
 onkeypress="document.form_name.submit();"
__________________
For my first trick watch me turn a zero into a one...

Reply With Quote
  #3  
Old May 2nd, 2008, 12:50 AM
lovesirius12 lovesirius12 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 10 lovesirius12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 24 m 41 sec
Reputation Power: 0
thanks but it still doesnt work. do i need to put additional code?

Quote:
Originally Posted by Dr_Rock
You cant do it in asp as it is a client side function, you will need to use javascript"

Code:
 onkeypress="document.form_name.submit();"

Reply With Quote
  #4  
Old May 2nd, 2008, 01:23 AM
soft903's Avatar
soft903 soft903 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 155 soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 13 m 58 sec
Reputation Power: 55
Hi,

What do you mean by "not working" ?
Please explain more.

Dr_Rock just give you an example as you provide no information of your code.

Try this example, whenever you type something (include backspace), "Testing" would be pop-up.
Code:
<html>
<script type="text/javascript">
function ClickbtnTest(){
alert('Testing');
}
</script>
<form name="Page">
Input Text:
<input type="text" onkeydown=ClickbtnTest() />
<input type="button" name="btnTest" value="Test" onClick=ClickbtnTest()>
</form>
</html>
You have to modify to what you want.

Hope it helps

Reply With Quote
  #5  
Old May 2nd, 2008, 01:33 AM
lovesirius12 lovesirius12 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 10 lovesirius12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 24 m 41 sec
Reputation Power: 0
thanks. the testing you posted worked.
but when i modified it to this:

Code:
<script type="text/javascript">
function ClickbtnTest(){
	document.form1.submit();
}
</script>



Code:
<form name="form1" method="post" action="index.asp">
<input name="medName" type="text" id="medName" size="50" width="350"onkeydown=ClickbtnTest() >
<input name="Display" type="submit" id="Display" value="Submit" onClick=ClickbtnTest()>
</form>


it doesnt return anything.. thanks for the time.

Quote:
Originally Posted by soft903
Hi,

What do you mean by "not working" ?
Please explain more.

Dr_Rock just give you an example as you provide no information of your code.

Try this example, whenever you type something (include backspace), "Testing" would be pop-up.
Code:
<html>
<script type="text/javascript">
function ClickbtnTest(){
alert('Testing');
}
</script>
<form name="Page">
Input Text:
<input type="text" onkeydown=ClickbtnTest() />
<input type="button" name="btnTest" value="Test" onClick=ClickbtnTest()>
</form>
</html>
You have to modify to what you want.

Hope it helps

Reply With Quote
  #6  
Old May 2nd, 2008, 02:21 AM
soft903's Avatar
soft903 soft903 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 155 soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 13 m 58 sec
Reputation Power: 55
Hi,

Your code looks fine.

Again what does "it doesnt return anything" mean ??
Page not submitted?
Or go to blank page?
Or something else?

Do you get what you want when simply click the button?

Add testing line to see whether enter the javascript function or not
Code:
<script type="text/javascript">
function ClickbtnTest(){
	alert('Submit');
	document.form1.submit();
}
</script>
Hope it helps

Reply With Quote
  #7  
Old May 2nd, 2008, 02:37 AM
lovesirius12 lovesirius12 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 10 lovesirius12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 24 m 41 sec
Reputation Power: 0
thank you very much for the time.
the testing line works. the message box showed up.

but the behavior is not the same as clicking the button.

and while on that topic, i noticed that after typing a character, the onkeydown was automatically triggered. do you know a way where that event should only be called after pressing the enter key.

thanks.

Quote:
Originally Posted by soft903
Hi,

Your code looks fine.

Again what does "it doesnt return anything" mean ??
Page not submitted?
Or go to blank page?
Or something else?

Do you get what you want when simply click the button?

Add testing line to see whether enter the javascript function or not
Code:
<script type="text/javascript">
function ClickbtnTest(){
	alert('Submit');
	document.form1.submit();
}
</script>
Hope it helps

Reply With Quote
  #8  
Old May 2nd, 2008, 03:07 AM
soft903's Avatar
soft903 soft903 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 155 soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level)soft903 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 13 m 58 sec
Reputation Power: 55
Hi,

Add function to check whether Enter is pressed
Code:
<script type="text/javascript">
function CheckEnterKey(e) {
if(window.event) {
	// IE
	keynum = e.keyCode;
} else if(e.which) {
	// Netscape/Firefox/Opera
	keynum = e.which;
}
if (keynum == 13) {
	// 13: Enter
	return true;
} else {
	return false;
}
}
function ClickbtnTest(event){
	if (CheckEnterKey(event)) {
		document.form1.submit();
	}
}
</script>

<!-- CODE -->

<form name="form1" method="post" action="index.asp">
<input name="medName" type="text" id="medName" size="50" width="350" onkeypress=ClickbtnTest(event)>
<input name="Display" type="submit" id="Display" value="Submit" onClick=ClickbtnTest(event)>
</form>
Hope it helps

P.S. maybe you should ask moderator to move this thread to "HTML, JavaScript And CSS Help".

Reply With Quote
  #9  
Old May 2nd, 2008, 06:38 AM
lovesirius12 lovesirius12 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 10 lovesirius12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 24 m 41 sec
Reputation Power: 0
thanks a lot. i tried it but when i pressed enter, it still didnt do the actions that the clicking of the button does.

And sorry if i posted this on the wrong thread.

Reply With Quote
  #10  
Old May 2nd, 2008, 07:24 AM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2004
Posts: 2,831 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 15 h 16 m 28 sec
Reputation Power: 57
Do you mean the FORM was not submitted?
__________________
selwonk

Reply With Quote
  #11  
Old May 6th, 2008, 07:37 PM
lovesirius12 lovesirius12 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 10 lovesirius12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 24 m 41 sec
Reputation Power: 0
Quote:
Originally Posted by selwonk
Do you mean the FORM was not submitted?


i think the form was submitted, but the procedures that the button does when it was clicked wasn't called.

thanks.

Reply With Quote
  #12  
Old May 8th, 2008, 07:37 PM
lovesirius12 lovesirius12 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 10 lovesirius12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 24 m 41 sec
Reputation Power: 0
thanks a lot for those who heloed. it's working fine now.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > General - Question - Key Down on TextBox


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |