View Full Version : Command Button & Functions
12-08-2004, 03:38 AM
I wish to switch the onclick event of a Command Button between Functions based upon the onfocus event of a text Field. For example, I shall use the onclick event of one Button to fill in data in many Text Fields as I tab from field to field. How would I code this?
12-08-2004, 04:58 AM
I read your post several times but I didn't get what you really wanted. Can you explain again?
you want a button's onClick event to change based on where its focus is? I didn't understand everything after "for example" though..
12-10-2004, 01:13 AM
I apologize for the initial ambiguity. I hope this is more concise. My form has four Text Fields and one Command Button. I wish to click on the Command Button and have it pass its Value to whichever Text Field has the Focus. How do I code this?
12-10-2004, 02:08 AM
if (currentField) currentField.value = val;
<input type="button" name="Set" onclick="setCurrentField('hello!')" />
<input type="text" name="txt1" onfocus="currentField=this" />
<input type="text" name="txt2" onfocus="currentField=this" />
<input type="text" name="txt3" onfocus="currentField=this" />
<input type="text" name="txt4" onfocus="currentField=this" />
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.