Hi, is it possible to change a form text field to this.blur() from a
separate function? So, what I want to do is when a button is click it
will runblur(), and cause form input name "xyz" to go into a
this.blur() state so nobody can type into it. Can this be done?
Thanks for anyone's help!
Sincerely,
Alex 7 1501
<Ra*********@hotmail.com> skrev i meddelandet
news:11**********************@l41g2000cwc.googlegr oups.com... Hi, is it possible to change a form text field to this.blur() from a separate function? So, what I want to do is when a button is click it will runblur(), and cause form input name "xyz" to go into a this.blur() state so nobody can type into it. Can this be done? Thanks for anyone's help!
Pass a reference to the text field to the function:
function runblur(inTextFieldRef){
inTextFieldRef.blur();
}
You could then have:
<form.....>
<input type="text" id="mytext">
<input type="button" onclick="runblur(document.getElementById('mytext') );">
</form>
You'll find the going *much* easier if you take the time to read up on basic
Javascript syntax.
--
Joakim Braun Ra*********@hotmail.com wrote: Hi, is it possible to change a form text field to this.blur() from a separate function? So, what I want to do is when a button is click it will runblur(), and cause form input name "xyz" to go into a this.blur() state so nobody can type into it. Can this be done? Thanks for anyone's help!
Sincerely,
Alex
If you want a text input that the user can't modify, use the
'readonly' attribute:
<input type="text" size="20" value="blah blah" readonly>
Using blur() in the manner you suggest will likely cause you
problems - blur() is not a state, it is a method.
--
Rob
Joakim Braun wrote: <Ra*********@hotmail.com> skrev i meddelandet news:11**********************@l41g2000cwc.googlegr oups.com...
Hi, is it possible to change a form text field to this.blur() from a separate function? So, what I want to do is when a button is click it will runblur(), and cause form input name "xyz" to go into a this.blur() state so nobody can type into it. Can this be done? Thanks for anyone's help!
Pass a reference to the text field to the function:
function runblur(inTextFieldRef){ inTextFieldRef.blur(); }
Ignoring that the concept of burring an input in order to mimic
setting the readonly attribute true seems flawed from the start.
Anyhow, a better function is:
function runblur(inTextFieldRef){
if ( inTextFieldRef.blur ) {
inTextFieldRef.blur();
}
}
You can't assume all browsers support all methods for all
elements. You could then have:
<form.....> <input type="text" id="mytext"> <input type="button" onclick="runblur(document.getElementById('mytext') );"> </form>
This is hardly a test of the function: the act of clicking on
the second input will cause 'mytext' to blur anyway. A better
test is:
<input type="text" onclick="callBlur(this);" value="Blur me">
<script type="text/javascript">
function runblur() {
// as above
}
function callBlur(x){
runblur(x);
}
</script>
--
Zif
Joakim Braun wrote: <Ra*********@hotmail.com> skrev i meddelandet news:11**********************@l41g2000cwc.googlegr oups.com... Hi, is it possible to change a form text field to this.blur() from
a separate function? So, what I want to do is when a button is click
it will runblur(), and cause form input name "xyz" to go into a this.blur() state so nobody can type into it. Can this be done? Thanks for anyone's help! Pass a reference to the text field to the function:
function runblur(inTextFieldRef){ inTextFieldRef.blur(); }
You could then have:
<form.....> <input type="text" id="mytext"> <input type="button"
onclick="runblur(document.getElementById('mytext') );"> </form>
You'll find the going *much* easier if you take the time to read up
on basic Javascript syntax.
-- Joakim Braun
.........Sorry, I should have given more information - the attribute I
want to mimic is: <input type="text" id="mytext"
onfocus="this.blur();">, so when that function is called "mytext" will
onfocus blur and behave that way. Can this weird function be done?
Sincerely--- Alex.
RobG wrote: Ra*********@hotmail.com wrote: Hi, is it possible to change a form text field to this.blur() from
a separate function? So, what I want to do is when a button is click
it will runblur(), and cause form input name "xyz" to go into a this.blur() state so nobody can type into it. Can this be done? Thanks for anyone's help!
Sincerely,
Alex
If you want a text input that the user can't modify, use the 'readonly' attribute:
<input type="text" size="20" value="blah blah" readonly>
Using blur() in the manner you suggest will likely cause you problems - blur() is not a state, it is a method.
-- Rob
Hi there. In my situation I want to cause that method to happen via a
remote function(), from an iframe. Do you know how to do this?
Alex Ra*********@hotmail.com wrote: RobG wrote:
[...] If you want a text input that the user can't modify, use the 'readonly' attribute:
<input type="text" size="20" value="blah blah" readonly>
Using blur() in the manner you suggest will likely cause you problems - blur() is not a state, it is a method.
-- Rob
Hi there. In my situation I want to cause that method to happen via a remote function(), from an iframe. Do you know how to do this?
"that method" being making the input readonly?
<form action="">
<input type="text" size="20" name="zz">zz<br>
<input type="button" value="Make zz readonly" onclick="
if (this.form.zz.readOnly) {
this.form.zz.readOnly = false;
this.value = 'Make zz readonly';
} else {
this.form.zz.readOnly = true;
this.value = 'Make zz editable';
}
">
</form>
--
Rob
RobG wrote: Ra*********@hotmail.com wrote: RobG wrote: [...] If you want a text input that the user can't modify, use the 'readonly' attribute:
<input type="text" size="20" value="blah blah" readonly>
Using blur() in the manner you suggest will likely cause you problems - blur() is not a state, it is a method.
-- Rob
Hi there. In my situation I want to cause that method to happen
via a remote function(), from an iframe. Do you know how to do this?
"that method" being making the input readonly?
<form action=""> <input type="text" size="20" name="zz">zz<br> <input type="button" value="Make zz readonly" onclick=" if (this.form.zz.readOnly) { this.form.zz.readOnly = false; this.value = 'Make zz readonly'; } else { this.form.zz.readOnly = true; this.value = 'Make zz editable'; } "> </form>
-- Rob
Exceptional, Rob! It works.
--Alex This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: CW |
last post by:
I wrote an HTML based chat application. The front end is built entirely on
HTML + javascript. Essentially, I have a hidden frame that's refreshed
frequently and any new messages are displayed in...
|
by: lazar |
last post by:
I'm triing to write script that close popup window, when user click
outside the popup.
Script below is working fine in firefox (v1.0.3), but not in IE.
I tried also to print hello but still...
|
by: Advocated |
last post by:
Hey all, thanks for taking the time to read this in the first place.
Anyway, ill try and keep it simple. In my program, if i type $ man something
it should read in the 2 words, man and something...
|
by: TN Bella |
last post by:
I have a simple text box called txtrefnum, if the user enters a number
length less than 9 characters long than I need to have lead zeros
added to it. Does anyone know how to do this? I couldn't...
|
by: Bill Borg |
last post by:
Hello,
I would like to skip over a hyperlink in the tab order. The link is not that
important, and I don't mind that they have to click to get it.
I have tried OnFocus="this.blur();" on the...
|
by: pamelafluente |
last post by:
I am still working with no success on that client/server
problem. I need your help. I will submit simplified versions
of my problem so we can see clearly what is going on.
My model:
A client...
|
by: sicapitan |
last post by:
// add event
_i = "'"+i+"'";
/* Event.observe('field'+i, 'blur', function(e) {
updateField('"'+i+'"', "value", "$F(this)") });*/
Event.observe('field'+i, 'blur', function(e) { updateField("1",...
|
by: Gerdus van Zyl |
last post by:
Does anyone have a relatively fast gaussian blur implemented in pure
python? Below is my attempt but it takes 2.9 seconds for a 320x240
image. Image comes from byte string: self.array =...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |