adding events to an input box at runtime

R

Robert Bravery

HI all,

I have a form for searches on a mysql database/table. The form has on input
text box, and several pushbuttons. Depending on which pushbutton is
selected, the search is then done on a specific field. One of them isa date
field.
How can I add or change the onfocus, onblur events of the input box to one
that is relevant to the type of search being done. For example, I have some
date format and valadation function, I would like to change the inputs
onblur and onkeyup to functions specific for date, and then when region
pushbutton is selected to change those same events to one spevific for
region
Can thin be done, if not what are the alternatives.

Thanks
Robert
 
J

Joshie Surber

I have a form for searches on a mysql database/table. The form has on input
text box, and several pushbuttons. Depending on which pushbutton is
selected, the search is then done on a specific field. One of them isa date
field.
How can I add or change the onfocus, onblur events of the input box to one
that is relevant to the type of search being done. For example, I have some
date format and valadation function, I would like to change the inputs
onblur and onkeyup to functions specific for date, and then when region
pushbutton is selected to change those same events to one spevific for
region
Can thin be done, if not what are the alternatives.

I am not sure I understand your problem. What I think you are asking is
if you can do something like:
window.onload = function() {
window.getElementById('searchByDateRadio').onchange = function() {
if (self.checked) window.getElementById('textBox').onblur =
valiDate;
else window.getElementById('textBox').onblur = null;
}
}

(Please excuse that I haven't tested this code, and it could be cleaned
up quite a bit)

If this is not what you are looking for, please give us some kind of
URL where we can see what you are trying to do.
 
R

Robert Bravery

Hi Josie,

I think you have understood half, or maybe more presise I explained half
What you have done in the onload event is exactly what I am looking for, but
when a user his/her select to the date radiobutton.
This once the page has already loaded.
It is initially set to have the claimno radiobutton set, and the inputbox
accepts char, the onblur is set to a cleanchar funtion
Now when the user changes to the date radiobutton, the onblur event should
be set to a dateformat function
The example you gave, would this achieve what I am trying to do??

Hope you understand more clearly now

Thanks
Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top