Results 1 to 5 of 5

Thread: Cutting out Cutting

  1. #1

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    I have a text box on a form but don't want it to be changed. I've used the tip from http://webreference.com/js/tips/991114.html to make sure that the user can not press keys to change it. My problem is is that the user can still cut from this text box. I thought about using the script to cut out the right mouse button click, but then there is still a cut in the Edit menu in Explorer.
    I do have a hidden text box as well with the text box I don't want changing, but to use this I need something like an onChange statement that can tell if text has been cut from the text box to implement it, but I can't find one that does this.
    I can't use plain text before anyone says anything because I use some JavaScript to change this text, and I can't find anyway of using JavaScript to change normal text even with using CSS.
    Hope I've explained myself OK and everyone understands what I'm on about and can help!!

  2. #2
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810

    Thumbs up DIV block for CSS?

    The follwing example uses plain text and allows the modification of the text programatically.
    To prove this also works with a CSS, I have included a style section which can be moved to a stylesheet if you prefer.
    Code:
    <html>
    <head>
    <title>Modify text programatically in a webpage</title>
    <script language="VBScript">
    <!--
    	Sub ChangeText()
    		Select Case oText.innerText
    			Case "Text"
    				oText.innerText = "The text has changed!"
    			Case "The text has changed!"
    				oText.innerText = "Text"
    		End Select
    	End Sub
    -->
    </script>
    <style>
    	DIV.mycss 
    	{
    	    FONT-WEIGHT: bold;
    	    COLOR: red
    	}
    </style>
    </head>
    <body>
      <p>
        <div class="mycss">
        This is some test <a id="oText">Text</a>
        </div>
      </p>
      <input type="button" name="oButton" value="Change Text" onclick="ChangeText"></input>
    </body>
    </html>
    This is a lot easier to use than trying to capture the changes to a disabled text box!

    Let me know if this works!
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  3. #3

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    That works fine with ten of my labels. But for some reason however much I try the following two will not change:

    <a id="status"></a> and <a id="location"></a>. Any idea why?

  4. #4
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810
    Try to name your objects without using reserved words. This may cause unreported errors:
    Code:
    <a id="oStatus"></a> and <a id="oLocation"></a>
    P.S. You can use the <span> tag instead of an <a> tag if you prefer.
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  5. #5

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    of course!
    yep that works fine now. Cheers very much for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width