• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Java Script Problem

Guest
May 08, 2006 May 08, 2006

Copy link to clipboard

Copied

ok guys , here is the Dilema .
I have three button in my Paye of type="button" so what i want to do is whenever user press Enter on the Key board then one of the button let say 'search' get focus and function corresponding to that button should get invoked .

i know it will be some thing like

if (window.event.keyCode == 13)
{
// what ever .
}
but where actaully i have to place it i mean what event will invoke it in the page

Or How to make a Default Button in coldfusion ?

any idea ?
TOPICS
Advanced techniques

Views

488

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 08, 2006 May 08, 2006

Copy link to clipboard

Copied

Instead of having type=button, have type=submit.

Make your js run when your form is submitted.
<form onsubmit="your js function">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 08, 2006 May 08, 2006

Copy link to clipboard

Copied

Dan in ASP there is Code Available to make button A default one . i was wondering is there any thing like that in coldfusion also ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 08, 2006 May 08, 2006

Copy link to clipboard

Copied

Getting down to basics, you say your form has three buttons. What do they do?

I don't understand the concept of a default button. Could you explain it in less than 100 words?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 08, 2006 May 08, 2006

Copy link to clipboard

Copied

Dan I think i Did it . to make a button default one can add this code in the <body>
so now when enter will be hit this function will execute .

<script>
document.onkeydown = function ()
{
if (window.event.keyCode == 13 ' && document.form.buttonname.value){
//whatever
}

}
</script>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 08, 2006 May 08, 2006

Copy link to clipboard

Copied

LATEST
Here is another variation... (same result)

<script language="javascript">
function key() { if (window.event.keyCode == 13) { document.getElementById("button1").focus(); } }
document.onkeypress=key;
</script>
<html><body><input type="button" id="button1" value="one" /><input type="button" id="button2" value="two" /><input type="button" id="button3" value="three" /></body></html>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation