Click to See Complete Forum and Search --> : Submit Button Help


Jick
07-02-2003, 12:16 PM
I have this chat form that has a send button:

http://kd7pyo.infinitypages.com/chat/

It also has a message box and you will notice if you type a message you have to hit the send button because if you just hit the return key it will add another line. Is it possible to have it so when you hit the return key it will do the same action as the send button does? Instead of put another line I want it to send if you hit the return key. Thanks for any help. :D

Jick
07-02-2003, 02:23 PM
I want a textarea because I still want them to be able to type long sentances and see what they are typing. So is it possible to have a textarea and still do what I want?

Jona
07-02-2003, 03:08 PM
Originally posted by Dave Clark
Try something like this:

<textarea name="myText" onkeydown="
var key = (window.Event) ? event.which : event.keyCode;
if (key == 13) this.form.submit();
return true;"></textarea>

Dave

Actually, if you look at the code, you'll see that it uses Javascript to submit a hidden form in the IFrame. So instead of this.form.submit(); it would be top.iframeName.formName.submit();

[J]ona

Jona
07-02-2003, 03:17 PM
That's cool. Just thought I'd say something so that Mjdimick doesn't end up confused about why it doesn't work, when the code is actually fine. :)

[J]ona

Jick
07-02-2003, 04:01 PM
Jona,
And that will also still allow the send button too? So they can submit by hitting the send button AND by hitting the return key!

Jona
07-02-2003, 04:12 PM
Originally posted by mjdimick
Jona,
And that will also still allow the send button too? So they can submit by hitting the send button AND by hitting the return key!

Yup.

[J]ona

Jona
07-02-2003, 04:18 PM
Originally posted by Dave Clark
Actually, Jona (now that I think about it), the code I posted will work perfectly fine -- as is -- because what I supplied goes directly in the FORM that is to be submitted. Your code, on the other hand, is probably more in conjunction with the SEND button (which I haven't looked at) and, therefore, your code will not work in the scenario I previously posted. In other words, the SEND button does not have to be changed to use the code I posted.

*Thinks about it.* Actually, Dave (now that I think about it), the code you posted will work prefectly fine -- as is -- because what you supplied goes directly in the FORM that is to be submitted. My code, on the other hand, is probably more in conjunction with the SEND button (which you haven't looked at, probably) and, therefore, my code will not work in the scenario you previously posted. In other words, the SEND button does not have to be changed to use the code you posted.

:D:D:D

[J]ona

Jick
07-02-2003, 06:54 PM
Ok, just now got back to see my post. Hmm... Wow! In all the confusion I lost which way I should do it. Which method should I use? Jona's or Dave's? God you guys are so good you can have fun while doing this! I have to have to think really hard usally, but I suppose thats just cause I'm so dumb. Lol... :p

Jona
07-02-2003, 06:55 PM
Dave's method will work fine.

[J]ona

Jick
07-02-2003, 09:31 PM
Well I tryed dave's method but it did not work. Don't forget I also have another function that dose something on keydown with my textarea already. Maybe thats inerfering with the one you had me try just now. After I inserted it and went to the page and tryed it all it does is disable the send button when I type the return key. We have that other thing already that disables it when you insert a return so I think thats what is inerfering. Is there another way to do this?

Jick
07-04-2003, 02:47 AM
Well I just tried what Dave said and all it does is flicker the page and then add a whole bunch of garbage to the end of the link in the address bar of IE, but overall it dosn't even add the post. I need to know if there is another way? I'm running IE6. I want for this to be usable for as most browsers as possible. Thanks. :)

Jick
07-04-2003, 09:43 AM
Yes, I put the code in exactally as you posted it on the forum. I changed no part of it. I changed it back though so it will still be operational for my visitors. I wunder what I could be doing wrong?

Jick
07-04-2003, 10:46 AM
I changed my mind. I decided that I don't want that. I just wish I could figure out how to make it so the send button gets re-disabled if you click anywhere else. You notice that when you go to the page the send button is disabled then when you click inside the textarea the send button becomes enabled. I want it so when you click back outside of the textarea the send button gets re-disabled. Is this possible?

Jick
07-04-2003, 10:53 AM
Ok, thanks anyway! You've been a big help.

:D (I will take answers from anybody else.) :D

Jona
07-04-2003, 10:59 AM
Originally posted by mjdimick
I just wish I could make is so that the send button gets re-disabled when you click anywhere else.

You would use onBlur="this.form.elements[1].disabled=true;"

[J]ona

Jick
07-04-2003, 11:21 AM
I inserted the exact code you gave me into my send button, but its not working. I'll click somewhere else and it dosn't disable the button. Was I suposed to insert that into the send button? Is there something I would have to chage for it to work on my form? Thanks for your help. ;)

Jona
07-04-2003, 11:39 AM
Originally posted by mjdimick
Was I suposed to insert that into the send button?

Actually, you need to put it in the TEXATAREA. :)

[J]ona