access textbox value which is in datagrid with javascript

Discussion in 'JavaScript' started by altinburak, Aug 13, 2008.

  1. #1
    Hi;

    I have a datagrid which has some textboxes and other controls. I want to clear the text in textbox when the user focus the textbox.

    How can I do that ? if someone tell me how can i access the value of the textbox in datagrid with javascript, I will be very happy

    Thanks
     
    altinburak, Aug 13, 2008 IP
  2. mallorcahp

    mallorcahp Peon

    Messages:
    141
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    add onfocus="this.value='';" to the textox ... like this:
     
    mallorcahp, Aug 13, 2008 IP
  3. altinburak

    altinburak Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it works good thank you. I have another question related to it, I want to control the value first, then I want to clear it.

    For example:

    if (value="qwerty")
    {
    this.value='';
    }

    Can I do it with function like above ? and HOW ?
     
    altinburak, Aug 13, 2008 IP
  4. mallorcahp

    mallorcahp Peon

    Messages:
    141
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    quick an easy way would be this:

    try type "qwerty" put the focus out of the field and then back in it will work ...

    Alternative is to write a function and then call that function but not absolutely necessary I suppose.
     
    mallorcahp, Aug 13, 2008 IP
  5. altinburak

    altinburak Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    it works fine

    Thanks a lot :)
     
    altinburak, Aug 13, 2008 IP
  6. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #6
    use substr() function to replace values.
     
    olddocks, Aug 13, 2008 IP