Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 853 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Javascript :

AJAX Problem

Thread title: AJAX Problem
Closed Thread    
    Thread tools Search this thread Display Modes  
08-18-2007, 08:43 AM
#1
Garrett is offline Garrett
Status: Waving
Join date: Aug 2005
Location:
Expertise:
Software:
 
Posts: 2,694
iTrader: 11 / 100%
 

Garrett is on a distinguished road

Send a message via MSN to Garrett

  Old  AJAX Problem

I am using Prototype for an AJAX script I made, the only problem is I have to hit the submit button, I can't hit Enter..

Is there anyway, to find out how to make it when you hit enter it will do it?

I was thinking of doing an if like:
Code:
document.onkeypress = function(){
if(document.getElementById('FORMID').focus){
ajaxCall();
}
}
Only problem is that it doesn't say when and what key it will work on...

I can only show the project to a select few, as it's very close to me. I don't think I would need to show anyone for this though.

08-18-2007, 01:19 PM
#2
Choco is offline Choco
Status: Member
Join date: Jul 2007
Location: USA
Expertise:
Software:
 
Posts: 240
iTrader: 2 / 100%
 

Choco is on a distinguished road

Send a message via MSN to Choco

  Old

Originally Posted by Garrett View Post
I am using Prototype for an AJAX script I made, the only problem is I have to hit the submit button, I can't hit Enter..

Is there anyway, to find out how to make it when you hit enter it will do it?

I was thinking of doing an if like:
Code:
document.onkeypress = function(){
if(document.getElementById('FORMID').focus){
ajaxCall();
}
}
Only problem is that it doesn't say when and what key it will work on...

I can only show the project to a select few, as it's very close to me. I don't think I would need to show anyone for this though.
<script type="text/javascript">
x= "myFormId";
y=document.getElementById(x);
document.onkeydown = function(e) {
e=(e)?e:window.event;
k=e.keyCode;
if(k==13)
ajaxCall();
}
</script>

That should work. =)

08-28-2007, 05:46 AM
#3
CreativeLogic is offline CreativeLogic
CreativeLogic's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 1,078
iTrader: 6 / 100%
 

CreativeLogic is on a distinguished road

Send a message via MSN to CreativeLogic

  Old

If it's in the form use onsubmit within the form tag.

08-28-2007, 10:58 AM
#4
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

Originally Posted by CreativeLogic View Post
If it's in the form use onsubmit within the form tag.
Or, unobtrusively attach the submit handler onload/domready. You're using Prototype so it's easy to do that using Event.observe, also make use of the $ function rather than document.getElementById.

If you use the form's submit event, there's no need to look for which key was pressed, playing with the submit button, etc.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed