Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Default TextBox Text.....

Default TextBox Text.....

Scheduled Pinned Locked Moved Web Development
javascripthtmltools
15 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G greendragons

    Hello, I am trying to make a textbox with default text..as user clicks it should disappear.I succeeded in doing that but got struck while differing the classes of default text and user input... here is my code ............................................................................................................ <html> <head>       <style>                   .hint{color:blue;}           .real{color:black;}                 </style>      <script type="text/javascript">           window.onload = onchange;           function foc(){                if(this.value.length==0 || this.className=="hint"){                     this.value="";                     this.className=="real";                }                          }           function blur(){                if(this.value.length==0){                                         this.className = "hint";                     this.value="Enter";                }                          }           function onchange(){                var text = document.getElementById("textbox1");                                     &n

    N Offline
    N Offline
    Not Active
    wrote on last edited by
    #2

    greendragons wrote:

    want that the hint text should appear in blue and input in black.

    Not possible in the same textbox at the same time Basically you seem very confused as to how CSS and JavaScript actually work


    I know the language. I've read a book. - _Madmatt

    G 1 Reply Last reply
    0
    • N Not Active

      greendragons wrote:

      want that the hint text should appear in blue and input in black.

      Not possible in the same textbox at the same time Basically you seem very confused as to how CSS and JavaScript actually work


      I know the language. I've read a book. - _Madmatt

      G Offline
      G Offline
      greendragons
      wrote on last edited by
      #3

      Then how this feature i have seen on many sites....there must be some way to create it...any ideas...

      N 1 Reply Last reply
      0
      • G greendragons

        Then how this feature i have seen on many sites....there must be some way to create it...any ideas...

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #4

        Just because you've seen something done doesn't mean it was done the way you think it was. What you are asking for, applying two styles to the same textbox for two seperate pieces of text is not possible with HTML. With Flash or Silverlight it is.


        I know the language. I've read a book. - _Madmatt

        G O 2 Replies Last reply
        0
        • N Not Active

          Just because you've seen something done doesn't mean it was done the way you think it was. What you are asking for, applying two styles to the same textbox for two seperate pieces of text is not possible with HTML. With Flash or Silverlight it is.


          I know the language. I've read a book. - _Madmatt

          G Offline
          G Offline
          greendragons
          wrote on last edited by
          #5

          thnx for help...

          1 Reply Last reply
          0
          • N Not Active

            Just because you've seen something done doesn't mean it was done the way you think it was. What you are asking for, applying two styles to the same textbox for two seperate pieces of text is not possible with HTML. With Flash or Silverlight it is.


            I know the language. I've read a book. - _Madmatt

            O Offline
            O Offline
            Oakman
            wrote on last edited by
            #6

            Mark Nischalke wrote:

            What you are asking for, applying two styles to the same textbox for two seperate pieces of text is not possible with HTML.

            Set the background of the text box to transparent. Line it up directly over a label (maybe in a user control) Format the text of the textbox one way and the text on the label another. A kluge, but it'd meet the design parameters as written.

            Jon

            Rob Graham wrote:

            100% subsidies are very popular among the 50% of the population that pays no income tax...

            Soap Box 1.0: the first, the original, reborn troll-less

            G N 3 Replies Last reply
            0
            • O Oakman

              Mark Nischalke wrote:

              What you are asking for, applying two styles to the same textbox for two seperate pieces of text is not possible with HTML.

              Set the background of the text box to transparent. Line it up directly over a label (maybe in a user control) Format the text of the textbox one way and the text on the label another. A kluge, but it'd meet the design parameters as written.

              Jon

              Rob Graham wrote:

              100% subsidies are very popular among the 50% of the population that pays no income tax...

              Soap Box 1.0: the first, the original, reborn troll-less

              G Offline
              G Offline
              greendragons
              wrote on last edited by
              #7

              If u don't mind please write the code... Thnx.

              N O 2 Replies Last reply
              0
              • O Oakman

                Mark Nischalke wrote:

                What you are asking for, applying two styles to the same textbox for two seperate pieces of text is not possible with HTML.

                Set the background of the text box to transparent. Line it up directly over a label (maybe in a user control) Format the text of the textbox one way and the text on the label another. A kluge, but it'd meet the design parameters as written.

                Jon

                Rob Graham wrote:

                100% subsidies are very popular among the 50% of the population that pays no income tax...

                Soap Box 1.0: the first, the original, reborn troll-less

                G Offline
                G Offline
                greendragons
                wrote on last edited by
                #8

                Ohhhhh i got it...sry i was little confused...Thnx..thtz quite tricky and defenitely will work...

                O 1 Reply Last reply
                0
                • G greendragons

                  If u don't mind please write the code... Thnx.

                  N Offline
                  N Offline
                  Not Active
                  wrote on last edited by
                  #9

                  Hell, no!!!:mad::mad: Don't ask anyone else to do your work :mad::mad:


                  I know the language. I've read a book. - _Madmatt

                  1 Reply Last reply
                  0
                  • O Oakman

                    Mark Nischalke wrote:

                    What you are asking for, applying two styles to the same textbox for two seperate pieces of text is not possible with HTML.

                    Set the background of the text box to transparent. Line it up directly over a label (maybe in a user control) Format the text of the textbox one way and the text on the label another. A kluge, but it'd meet the design parameters as written.

                    Jon

                    Rob Graham wrote:

                    100% subsidies are very popular among the 50% of the population that pays no income tax...

                    Soap Box 1.0: the first, the original, reborn troll-less

                    N Offline
                    N Offline
                    Not Active
                    wrote on last edited by
                    #10

                    Oakman wrote:

                    A kluge,

                    To say the least :-D


                    I know the language. I've read a book. - _Madmatt

                    O 1 Reply Last reply
                    0
                    • G greendragons

                      If u don't mind please write the code... Thnx.

                      O Offline
                      O Offline
                      Oakman
                      wrote on last edited by
                      #11

                      greendragons wrote:

                      If u don't mind please write the code...

                      I don't mind at all. As long as you don't mind depositing $100.00 in my bank account. I am a professional. I write code for money.

                      Jon

                      Rob Graham wrote:

                      100% subsidies are very popular among the 50% of the population that pays no income tax...

                      Soap Box 1.0: the first, the original, reborn troll-less

                      1 Reply Last reply
                      0
                      • N Not Active

                        Oakman wrote:

                        A kluge,

                        To say the least :-D


                        I know the language. I've read a book. - _Madmatt

                        O Offline
                        O Offline
                        Oakman
                        wrote on last edited by
                        #12

                        Kluge-R-Us

                        Jon

                        Rob Graham wrote:

                        100% subsidies are very popular among the 50% of the population that pays no income tax...

                        Soap Box 1.0: the first, the original, reborn troll-less

                        1 Reply Last reply
                        0
                        • G greendragons

                          Ohhhhh i got it...sry i was little confused...Thnx..thtz quite tricky and defenitely will work...

                          O Offline
                          O Offline
                          Oakman
                          wrote on last edited by
                          #13

                          the answer to the question you delighted is "z-index"

                          Jon

                          Rob Graham wrote:

                          100% subsidies are very popular among the 50% of the population that pays no income tax...

                          Soap Box 1.0: the first, the original, reborn troll-less

                          1 Reply Last reply
                          0
                          • G greendragons

                            Hello, I am trying to make a textbox with default text..as user clicks it should disappear.I succeeded in doing that but got struck while differing the classes of default text and user input... here is my code ............................................................................................................ <html> <head>       <style>                   .hint{color:blue;}           .real{color:black;}                 </style>      <script type="text/javascript">           window.onload = onchange;           function foc(){                if(this.value.length==0 || this.className=="hint"){                     this.value="";                     this.className=="real";                }                          }           function blur(){                if(this.value.length==0){                                         this.className = "hint";                     this.value="Enter";                }                          }           function onchange(){                var text = document.getElementById("textbox1");                                     &n

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #14

                            Use

                            <html>
                            <head>
                            <style>

                                  .hint{color:blue;}
                                  .real{color:black;}
                                 
                              </style>
                             <script type="text/javascript">
                                  window.onload = onchange;
                                  function foc(){
                                       if(this.value.length==0 || this.className=="hint"){
                                            this.value="";
                                            document.getElementById('textbox1').className = 'real';
                                            //this.className=="real";
                                       }
                                      
                                  }
                                  function blur(){
                                       if(this.value.length==0){
                                           document.getElementById('textbox1').className = 'hint';
                                            //this.className = "";
                                            this.value="Enter";
                                       }
                                      
                                  }
                                  function onchange(){
                                       var text = document.getElementById("textbox1");
                                                
                                            text.onfocus = foc;
                                            text.onblur = blur;
                                 
                                    }         
                             </script>
                            

                            </head>
                            <body>
                            <input type="text" id="textbox1" class="hint" value="Enter"/>
                            </body>
                            </html>

                            Regards Aman Bhullar www.arlivesupport.com[^]

                            G 1 Reply Last reply
                            0
                            • L Lost User

                              Use

                              <html>
                              <head>
                              <style>

                                    .hint{color:blue;}
                                    .real{color:black;}
                                   
                                </style>
                               <script type="text/javascript">
                                    window.onload = onchange;
                                    function foc(){
                                         if(this.value.length==0 || this.className=="hint"){
                                              this.value="";
                                              document.getElementById('textbox1').className = 'real';
                                              //this.className=="real";
                                         }
                                        
                                    }
                                    function blur(){
                                         if(this.value.length==0){
                                             document.getElementById('textbox1').className = 'hint';
                                              //this.className = "";
                                              this.value="Enter";
                                         }
                                        
                                    }
                                    function onchange(){
                                         var text = document.getElementById("textbox1");
                                                  
                                              text.onfocus = foc;
                                              text.onblur = blur;
                                   
                                      }         
                               </script>
                              

                              </head>
                              <body>
                              <input type="text" id="textbox1" class="hint" value="Enter"/>
                              </body>
                              </html>

                              Regards Aman Bhullar www.arlivesupport.com[^]

                              G Offline
                              G Offline
                              greendragons
                              wrote on last edited by
                              #15

                              Thtz great working and exactly i wanted to do...:) But please can you explain how class changed....i was using this.className...... and u used document.getElementById("textbox1").className=...... Apparently both are same since the value of this is document.getElementById("textbox1")..... but in this way it's working.....how????

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups