CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Button Focus

Print topic Send  topic

Author Message
datadoit.com
Posted: 04/04/2005, 11:58 AM

CCS 2.3; PHP4

I have a login form with two buttons, reset and login. Reset just redirects
back to the same page and clears the contents of the user name and password.
No problem. Submit logs in.

The reset button has Default Button = No, Enable Validation = No. The login
button has Default Button = Yes, Enable Validation = Yes. However, when
hitting the enter key it's invoking the reset button and not the login
button.

These settings are obviously being ignored. Where to do look or what do I
set to enable the login button as the default button? Thnx.

-MikeR

lvalverdeb

Posts: 299
Posted: 04/04/2005, 12:51 PM

Hi Mike,

Try the javascript solution explained the following link:

http://www.devx.com/vb2themax/Tip/18846

Luis
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message
datadoit.com
Posted: 04/04/2005, 2:10 PM

Cool. The doc says:

Now, in the input controls declaration you just have to call this function
when a button is pressed, by handling the onKeyPressed client-side event,
and pass a reference to the default button:

<asp:Button Runat="server" ID="DefButton" />
<asp:TextBox Runat="server" ID="FirstName" onKeyDown= _
"KeyDownHandler(DefButton)" />

How can this be implemented in PHP and CCS?

Thanks!

lvalverdeb

Posts: 299
Posted: 04/04/2005, 4:41 PM

Hi Mike,

On the FORM "Format Tab", section Events, find the onkeypress event and enter:
  
  KeyDownHandler(this.Button_DoLogin)   
BTW, I was unable to replicate the problem you describe (i.e. the Default button works fine in my case) but I was able to get the functionally you describe. It is possible you may have some javacript or improperly closed HTML tags somewhere affecting the button's Default property.

Anyhow, I did test that the KeyDownHandler traps the Enter Key correctly and fires the click event accordingly.

Hope it works.

Luis

_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message
datadoit.com
Posted: 04/04/2005, 7:50 PM

I still couldn't get the KeyDownHandler function to work for me. Likely
something in the id naming. At any rate, I create the login form using the
builder, for which it only creates a single 'login' button. I then add
another button and use it as a 'reset' button - no validation and a redirect
to the same login page.

I noticed that when this button is to the left of the login button, it
becomes the default (despite settings in CCS). If I move the button over to
the right of the login button, the login button becomes the default. So
whoever is to the left wins.

-MikeR

Damian Hupfeld
Posted: 04/05/2005, 5:36 AM

Try changing the TAB order?

"datadoit.com" <mike@datadoit.com> wrote in message
news:d2sudh$ehj$1@news.codecharge.com...
>I still couldn't get the KeyDownHandler function to work for me. Likely
>something in the id naming. At any rate, I create the login form using the
>builder, for which it only creates a single 'login' button. I then add
>another button and use it as a 'reset' button - no validation and a
>redirect to the same login page.
>
> I noticed that when this button is to the left of the login button, it
> becomes the default (despite settings in CCS). If I move the button over
> to the right of the login button, the login button becomes the default.
> So whoever is to the left wins.
>
> -MikeR
>

datadoit.com
Posted: 04/05/2005, 7:59 PM

>Damian Hupfeld" <damian.hupfeld@itng.com.au> wrote in message
>news:d2u0nj$6ma$1@news.codecharge.com...
> Try changing the TAB order?
>

Unfortunately it appears to ignore the tab order designations. So no
change.

I'm seeing this behavior on every single form that I create with the
builder.... Button Focus is ignored, along with tab orders. The button with
the focus is the first button from left to right.

-MikeR

lvalverdeb

Posts: 299
Posted: 04/06/2005, 9:46 AM

Hi Mike,

You're right. I was able to replicate the behaviour you describe. I am also glad to report that the KeyDownHandler() function works just as well. What error are you getting? JavaScript related? As indicated for this to work as intented the Event must be handled at the form level. The HMTL view of my login form is as follows:
  
<table class="IEMFormTABLE" cellspacing="1" cellpadding="3" border="0">  
                <!-- BEGIN Error -->  
                <tr>  
                  <td class="IEMErrorDataTD" colspan="2">{Error}</td>   
                </tr>  
 <!-- END Error -->  
                <tr>  
                  <td class="IEMFieldCaptionTD">ID Usuario </td>   
                  <td class="IEMDataTD"><input class="IEMInput" maxlength="100" value="{login}" name="{login_Name}"> </td>   
                </tr>  
   
                <tr>  
                  <td class="IEMFieldCaptionTD">Contraseña </td>   
                  <td class="IEMDataTD"><input class="IEMInput" type="password" maxlength="100" value="{password}" name="{password_Name}"> </td>   
                </tr>  
   
                <tr>  
                  <td class="IEMFooterTD" nowrap align="right" colspan="2">  
                    <!-- BEGIN Button resetButton --><input class="IEMButton" type="submit" value="Reset" name="{Button_Name}"><!-- END Button resetButton -->    
                    <!-- BEGIN Button Button_DoLogin --><input class="IEMButton" type="submit" value="Login" name="{Button_Name}"><!-- END Button Button_DoLogin --> </td>   
                </tr>  
   
              </table>  
   
            </form>  


_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message
lvalverdeb

Posts: 299
Posted: 04/06/2005, 9:55 AM

I failed to include the form section of the HTML. Ironically, I accidentally pushed the space bar and the "left" button i.e. submit, sent the message!! Here's the complete HTML for the login form and the key parts are in bold:

  
<form name="{HTMLFormName}" action="{Action}" method="post" onkeypress="KeyDownHandler(this.Button_DoLogin)">  
table class="IEMFormTABLE" cellspacing="1" cellpadding="3" border="0">    
                <!-- BEGIN Error -->    
                <tr>    
                  <td class="IEMErrorDataTD" colspan="2">{Error}</td>     
                </tr>    
 <!-- END Error -->    
                <tr>    
                  <td class="IEMFieldCaptionTD">ID Usuario </td>     
                  <td class="IEMDataTD"><input class="IEMInput" maxlength="100" value="{login}" name="{login_Name}"> </td>     
                </tr>    
     
                <tr>    
                  <td class="IEMFieldCaptionTD">Contraseña </td>     
                  <td class="IEMDataTD"><input class="IEMInput" type="password" maxlength="100" value="{password}" name="{password_Name}"> </td>     
                </tr>    
     
                <tr>    
                  <td class="IEMFooterTD" nowrap align="right" colspan="2">    
                    <!-- BEGIN Button resetButton --><input class="IEMButton" type="submit" value="Reset" name="{Button_Name}"><!-- END Button resetButton -->      
                    <!-- BEGIN Button Button_DoLogin --><input class="IEMButton" type="submit" value="Login" name="{Button_Name}"><!-- END Button Button_DoLogin --> </td>     
                </tr>    
     
              </table>    
     
            </form>    

Luis
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message
datadoit.com
Posted: 04/06/2005, 5:31 PM

Well, lemme add that the browser I'm using is Firefox, so the javascript
function doesn't work. Here's what I've tried:

function KeyDownHandler(btn)
{
// process only the Enter key

/* This don't work in Firefox:
var keyCode = '';

if(window.event) {
keyCode = window.event.keyCode; // IE
}
else {
keyCode = e.which; // Mozilla?
}
*/

// This don't work either in Firefox:
var keyCode = (btn) ? event.keyCode : keyStroke.which;
if (keyCode == 13) {
// alert("You Hit Enter!");
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified
button
btn.click();
}
}
</script>

All is well in IE.

lvalverdeb

Posts: 299
Posted: 04/06/2005, 7:27 PM

Hi Mike,

here's a revised version of the KeyDownHandler function with support for IE, Mozilla/Firefox and I think Netscape:

  
function KeyDownHandler(e,btn)	{  
	// process only the Enter key  
	if(e && e.which){   
		characterCode = e.which  
	} else {  
		characterCode = e.keyCode;  
	}  
	if (characterCode == 13)	{  
	   // cancel the default submit  
       e.returnValue=false;  
       e.cancel = true;  
       // submit the form by programmatically clicking the specified button  
       btn.click();  
     }  
}  

Please also note that the calling parameters are now:

  
<form name="{HTMLFormName}" action="{Action}" method="post" onkeypress="KeyDownHandler(event,this.Button_DoLogin)">   

All the best

Luis
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message
datadoit.com
Posted: 04/07/2005, 5:55 AM

> here's a revised version of the KeyDownHandler function with support for
> IE,
> Mozilla/Firefox and I think Netscape:
>
> Luis
------------------------------

Beautiful! I must've spent hours last night trying to find the solution.
Thanks again Luis!

-MikeR

DonB
Posted: 04/08/2005, 10:26 AM

You might not be applying the tabindex propery correctly (and the attribute
is 'tabindex' not 'taborder' just to be confused about that).

Let's say you have a form with 3 buttons and you want the 'center' one to be
the default. Add the tabindex to 1 for the center button and do nothing to
the other two. Now the center button will be first in the tabindex ordered
list and will be the 'default' button. The other controls will be positioned
after that one button (press tab to see this work as you step through all
your form elements).

You can set the tabindex to -1 for any elements that should never get focus
(not recommended for mouse-less users!). All elements with no explict
tabindex are presumed to be tabindex=0.

The tabindex is followed in the order: 1, 2, 3, 4,etc. 0 (so that the zero
ones always fall after all those that are 1 or greater.

The tabindex defines *groups* of tabbed elements, not a simple ordered-list
to sequence through. Several form elements can be in group '1' and those
will all be tabbed through in the top-left to bottom-right order they appear
in your html, next all those with '2' will be tabbed through, and so on.

--
DonB

http://www.gotodon.com/ccbth


"datadoit.com" <mike@datadoit.com> wrote in message
news:d2vjam$ahn$1@news.codecharge.com...
> >Damian Hupfeld" <damian.hupfeld@itng.com.au> wrote in message
> >news:d2u0nj$6ma$1@news.codecharge.com...
> > Try changing the TAB order?
> >
>
> Unfortunately it appears to ignore the tab order designations. So no
> change.
>
> I'm seeing this behavior on every single form that I create with the
> builder.... Button Focus is ignored, along with tab orders. The button
with
> the focus is the first button from left to right.
>
> -MikeR
>
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.