newbie needs help

Discussion in 'JavaScript' started by Pål Monstad, Oct 3, 2014.

  1. #1
    I have a script showing words one by one on the screen. This works OK as I have entered the word list to be displayed in an array like

    var words = [];
    words.push({
    name: 'wordlist1',
    words: [
    'I','like','to','think','I','can','program'
    ]
    });
    Code (markup):
    I have several such wordlist in the same array, but now I like to have the user to add their own text in an input field. Is it possible to have some kind of a long text input field where the entered text is put into this array?

    If this is possible I ca use my existing script without too much modification.

    Thanks!
     
    Last edited by a moderator: Oct 3, 2014
    Pål Monstad, Oct 3, 2014 IP
  2. Sano000

    Sano000 Active Member

    Messages:
    52
    Likes Received:
    4
    Best Answers:
    5
    Trophy Points:
    53
    #2
    Hi,

    // Get the text from a textarea
    var userList = $('textarea.user-text').val()
    
    // create a new item
    userWordsData = {
      name: 'userList',
      words: userList.split(' ')
    }
    
    // add it to the words array
    words.push(userWordsData)
    Code (markup):
    also you and use concat method to append new array to exists one:
    words[0].words.concat( $('textarea').val().split(' ') )
    Code (markup):
     
    Sano000, Oct 3, 2014 IP
    sarahk likes this.
  3. Pål Monstad

    Pål Monstad Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    I wonder I I can have help to implement this? I'm too newbie to solve this myself. I can pay for the help (Paypal). What I need is some modifications at my test site www.limesurvey.no/ord/ where an option is added to the Options menu. There is a dropdown menu called "ordliste". I want the user to be able to add own words here via e.g. an option "own list" popping up a text input field where the user can enter og paste a list of word. Making them into a cookie belong the other cookie setting is great as the word list can be preserved. Anyone able to help me with this one?
     
    Pål Monstad, Oct 4, 2014 IP
  4. seductiveapps.com

    seductiveapps.com Active Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #4
    I can help you out.. Looks like it doesnt need to cost you much (in the order of 10 or 20 euros or something ;), let me know at how you want this done..
     
    seductiveapps.com, Oct 25, 2014 IP