web hosting and development forums
Web Design and Development Forums Archive


Index - HTML forum

text input node


Post reply

I want to have a text-input node respond to me pressing 'enter' without making it a form...
OnKeyUp or something
Why not make it a form?
Define "respond"
Onkeyup
I dont need it, and dont want it to reload the page. Klimapol: respond as in simulate a button-click
= someFunction that will check if it was enter... and then if so do something
What happens when the button is clicked though?
montanarry, k, 'll try that Klimapol, it works ;-P
What works how?
:D
optomeb, If you want it to get data, then you should use a form. Ever heard of gracefull fallback?
You keep glossing over the important part
You can catch the submit event, cancel it, and then use XHR instead
optomeb, you dont have to use a form just the <input> but i suggest you use a <form> and <input > in it
montanarry, how can I not let it reload the page when using a form?
.. dont put the Submit stuff :D
Or not even put it
Of course then you need a protocol for recieving feedback via XHR and knowing what to do with it
I dont know if they do submit if you wont put a <input type=SUBMIT>
optomeb, You could set it up so that if the user has JS, then the submit action gets blocked, but you does some XMLHTTPReq stuff to get the job done. If there is no JS, then the submit will do it's magic.
Action is required according to w3
On the server side, you'll hook them into the same functions, so you won't haveot know the difference.
optomeb, then also put onSubmit="return false" Or something like that but i dont know exact
montanarry, no you'd attach an event listener Cancel the event And then do XHR stuff instead Of course then you have to know how to use XHR and what to do with the response
What?
Nothing about it "just works"
Why cant he put event listener If the html sends the form after enter Then block it with the <form onSubmit="return false;"> I still bet 20 that it has to be this way :P
montanarry, That's an easy bet for you to make, being as none of us is on hand to collect.
montanarry,Using unobtrusive javascript also means not using html attributes to attach event handlers
Yeah easy cause i wont be able to collect money from you Poolkop, why html atributes... He can also do somewhere a script.. form.onSubmit=function Or he cant ?
montanarry,However, I believe you're basically saying the same thing. make the onSubmit event handler be the function that does your XHR juju, and then returns false. In the absense of JS, submit will do it's thing. Of course, then you'll want to do be careful to do your layering right server side.
He can, and he should. I think you forgot to read my negation
How exactly do I cancel the event?
optomeb, If the event handler you use returns false, you should be golden.
Well thats what i said or no ?
Well, I believe it does return false... but still!
Still what..
montanarry,I think the argument was actually about syaing myform.onSubmit=function blah(){} vs. saying <form onsubmit="return false;">
Well i said both
montanarry, it still reloads the page
Lemme try
montanarry,Then you'll have some difficulty finding a taker for your bet. I thought you were only saying the latter.
I said both
OK. I'm not that worried about it.
:D
montanarry,sorry, it was a false at the wrong place (apparently). It is a bit complex...
Ok i will check how it work If it works
I wish my could were faster.
optomeb, so you have a <input type="text" in it ?
Yep. The problem was that the onsubmit was applied by an onload. This would attach a function to the form, and the function returned false. That appeared not good enough So I hardcoded it (was okay anyway). It works perfectly for what it is build for Thanks.
So it works The page doesnt reload Gimme my money :P




Dubai Forum | Paris Forum | Webmaster Forum | Vegan Forum | Brisbane Forum | 3D Forum | Jobs in Dubai | Jobs in London | London UK Classifieds
Archive script by RedHo.com