1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

textbox

Discussion in 'JavaScript' started by AndrewP2020, Oct 30, 2020.

  1. #1
    Hi, first I'm not js programmer...but I need a bit of help.

    There is a textbox vaguely defined like this:

    <input class="somerandomname" value="">

    By typing text or using paste(from clipboard) element value, in the source code, visibly changes from empty one to match entered text.
    However when I try to use javascript to populate the textbox, although the text do visually appears inside,
    value is not changed, like in previous case, and the textbox is treated as empty.

    Is there something I can do to properly fill the box by use of js?
     
    AndrewP2020, Oct 30, 2020 IP
  2. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #2
    Post the code. I am sure it's something simple, but without the code, it'll be hard to get it working.
     
    qwikad.com, Oct 30, 2020 IP
  3. AndrewP2020

    AndrewP2020 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    What code, I do not have the class code. Both 'Submit' button and textbox seems like simple html code as you see the line above.
    I use simple getElementsByTagName to fill the textbox.
    The problem is even though it's visually filled, the button treats it as empty(does nothing) , I can even read the text from textbox to variable and display it with alert, but as long as it is filled by javascript (getElementsByTagName) it gets ignored by the button.
     
    AndrewP2020, Oct 30, 2020 IP
  4. iago111

    iago111 Member

    Messages:
    99
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    33
    #4
    I'm not exactly if this is what you mean, but JS does not automatically update the values of the element variables. Therefore it makes sense to use a framework like vue.js or react.js. (in vue.js you use v-model which automatically updates the value that has been entered in the input field)
     
    iago111, Nov 17, 2020 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #5
    THAT code. Are you assigning Element.value to what that gives you?

    What class?
     
    deathshadow, Dec 16, 2020 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #6
    That doesn't even make sense.
     
    deathshadow, Dec 16, 2020 IP
  7. AndrewP2020

    AndrewP2020 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #7
    I'm back with the same problem...hope here is a lot of patience reserved for me. :)

    With help of Developer Tools in chrome I found a function which handles different events(click, keyup, blur, input).
    The input event seems to be important because it's triggered when typing text or using paste(clipboard) into the textbox and calls yet another function,
    unlike "getElementsByTagName" which triggers only the selectionchange event.
    This explains why my text gets ignored.............. but it does not solve the problem.

    I'd post some code snippets but:
    - neither of functions or variables have meaningful names, just one or two letters.
    - rather privately if anyone would be interested
     
    AndrewP2020, Dec 24, 2020 IP
  8. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #8
    Can you post a jsfiddle or a codepen of the problem?
     
    sarahk, Jan 11, 2021 IP
  9. seedling

    seedling Active Member

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #9
    Check onKeyDown and onKeyUp... you should be able to trigger these on every keystroke of the textarea.
     
    seedling, Jan 21, 2021 IP