473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

need this.blur() help -- running it from a separate function

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

Jul 23 '05 #1
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
Jul 23 '05 #2
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
Jul 23 '05 #3
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
Jul 23 '05 #4

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.

Jul 23 '05 #5

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

Jul 23 '05 #6
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
Jul 23 '05 #7

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

Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
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...
2
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...
7
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...
6
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...
1
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...
16
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...
5
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",...
2
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 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.