Trying to set editor field name to cookie value. Comes up blank..

Trying to set editor field name to cookie value. Comes up blank..

nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2
      editor.on('initEdit', function getCookie(name) {

            var re = new RegExp(name + "=([^;]+)");
            var value = re.exec(document.cookie);
            return (value != null) ? unescape(value[1]) : null;

    var uname = getCookie("myCookie").replace("UserName=", "")


    editor.field('User').def(uname);

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 65,821Questions: 1Answers: 10,951 Site admin

    By the time the initEdit event occurs the default value has already been read and inserted as the value for the field. If you want to be able to set a value based on the cookie in initEdit, use field().val().

    Allan

  • nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2

    Thanks for the response Allan. I tried that too. Still blank.

  • allanallan Posts: 65,821Questions: 1Answers: 10,951 Site admin

    Could you give me a link to the page so I can check it out please.

    Allan

  • nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2

    Sorry, but I really can't. Information is confidential. I will see if there is something else I can do tomorrow as an alternative means of sharing.

  • nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2
    Answer ✓

    Resolved this issue can close.

This discussion has been closed.