Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem when settign From Controls readonly property to False

Posted on 2003-10-29
19
Medium Priority
?
403 Views
Last Modified: 2012-08-13
Hi All,

I have a for mon my page, and initially when the page loads all the controls are readonly. when the user clicks an edit button, a vbscript sub will set all the controls to writeable again. The problem I am facing is, that after setting al lthe controls to writeable, I can't type into the textboxes unless I first press the INSERT key on my keyboard.

Can anyone tell me how to overcome this problem or if its not possible, how to simulate an INSERT key press?Thanks in advance.
0
Comment
Question by:winnydapoo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 4
19 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 9641229
Try it with this method which is cross browser compatible with NS and IE, us the Blur effect


<script language="JavaScript">
function changeReadOnly(){
    for (i = 0 ; i < document.myForm.elements.length ; i++){
         document.myForm.elements[i].onfocus="";}}
</script>

<form name=myForm>
<input type=text name=a OnFocus="this.blur()">
<input type=text name=b OnFocus="this.blur()">
<input type=text name=c OnFocus="this.blur()">
<input type=button onClick=changeReadOnly()>
</form>
0
 

Author Comment

by:winnydapoo
ID: 9641280
Hi gary,

Do you have something liek that in Vbscript? Also, The onfocus="" doesn't change the readonly status right? I am nto sure how to change the readonly status in vbscript so I can't really test your solution!
0
 
LVL 58

Expert Comment

by:Gary
ID: 9641302
The onFocus stops the fields being editable, does it need to be compatible with earlier versions of NS?  Try my example as it is now (just that code) and you will see what I mean.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:winnydapoo
ID: 9641342
No what I need to do is, For each control in the form

Set it to WRITEABLE (Readonly=False)
Allow entry without having to press the Insert key
0
 
LVL 58

Expert Comment

by:Gary
ID: 9641506
<script language="JavaScript">
function changeReadOnly(){
    for (i = 0 ; i < document.myForm.elements.length ; i++){
         document.myForm.elements[i].style.readonly=false;}}
</script>

<form name=myForm>
<input type=text name=a style="readonly:true">
<input type=button onClick=changeReadOnly()>
</form>
0
 

Author Comment

by:winnydapoo
ID: 9641575
I can still only key in information after pressing the INSERT key. is there a way to simulate the INSERT keypress?
0
 
LVL 1

Expert Comment

by:Barraza
ID: 9642603
Winny
Can you show us some of your code of how you set all the controls to ready only?  This might help us to help you to set your controls to writable, without pressing the Insert button on your keyboard (since there is not a way to simulate the Insert button on your keyboard from a web page).
0
 

Author Comment

by:winnydapoo
ID: 9646799
It is something like this :

<script language="VBScript">
sub editrecord()
document.mrForm.a.readonly=false
end sub
</script>

<form name=myForm>
<input type=text name=a readonly>
<input type=button onClick=editrecord()>
</form>
0
 
LVL 58

Expert Comment

by:Gary
ID: 9646848
Does it have to be vbscript, try my example in my previous example, it's almost identical and does the same thing except it works without having to press the Insert key
0
 

Author Comment

by:winnydapoo
ID: 9647356
I don't think this works :

<script language="JavaScript">
function changeReadOnly(){
    for (i = 0 ; i < document.myForm.elements.length ; i++){
         document.myForm.elements[i].style.readonly=false;}}
</script>

<form name=myForm>
<input type=text name=a style="readonly:true">
<input type=button onClick=changeReadOnly()>
</form>

Because when I load a page containing only that code, the textbox is not readonly. I think the stye="readonly:true" doesn't work.
0
 

Author Comment

by:winnydapoo
ID: 9649616
I will add 90 points if anybody can help me get rid of the need to press insert before keying into the form...
0
 
LVL 1

Expert Comment

by:Barraza
ID: 9650828
Winny
I took your code segment and copied/pasted it into an asp document on my web server.  However the code worked fine (with the exception of the mrform which should have been myform), and I was not able to duplicate the error you are getting as far as the need to press Insert.  I'm wondering, maybe there is something else in your code that is causing it.  To find out, have you tried testing the simplified code segment you posted above?  Stick that into an asp page and let us know if that still forces you to press Insert.  If it doesn't, then there must be something else in your code that is causing it.  If it does, then I'd say it is something specific to your system.
Let us know.
0
 

Author Comment

by:winnydapoo
ID: 9654572
You are right! It must be something else in the page that is causing the requirement to press insert, any ideas on what might cause something like that?
0
 
LVL 1

Expert Comment

by:Barraza
ID: 9655436
I'll need to take a look at the rest of your code and I'll tell you.
0
 

Author Comment

by:winnydapoo
ID: 9656522
Can I email it to you? the code is a bit too large to paste, I ahven't tidied ti up yet.
0
 
LVL 1

Expert Comment

by:Barraza
ID: 9657510
Sure:
espamame@yahoo.com
0
 
LVL 1

Accepted Solution

by:
Barraza earned 880 total points
ID: 9658043
Winny,
What is happening is this:  You've got a maxlength on each of your input boxes and they are being filled from the recordset (rs).  When you populate the input boxes, they are being filled with blank spaces after the value.  All you need to do is trim them... for example:
value='" & rs("caddr1") & "'
becomes:
value='" & trim(rs("caddr1")) & "'

This should take care of your problem.  Let me know if it doesn't.
0
 

Author Comment

by:winnydapoo
ID: 9658326
Spot on! Thanks alot Barraza for taking the time to look at my code, realle helped me with that!
0
 
LVL 1

Expert Comment

by:Barraza
ID: 9658819
Any time  :D
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question