2

I want to customize my Jira and need to set a text input field to readonly in javascript / html. I got the following code already, which sets a default value into my customfield "summary":

   window.ATL_JQ_PAGE_PROPS =  $.extend(window.ATL_JQ_PAGE_PROPS, {

          triggerFunction: function(showCollectorDialog) {
            $('#feedback-button').on( 'click', function(e) {
                e.preventDefault();
                showCollectorDialog();
            });
        },

        fieldValues: {
            summary : 'Solution'
                }

          });

</script>

Next step would be to also set the "summary" to readonly, so users can't modify my predefined title anymore. I already tried "document.getElementById("summary").setAttribute("readonly", true);" and similar stuff but it didn't work out. Mayb I did something wrong since I'm not a programmer and someone has an advice?

Thanks in advance

9
  • 1
    Does this answer your question? What is the correct readonly attribute syntax for input text elements? Commented Apr 17, 2020 at 10:59
  • Thanks for fast reply, but I already tried some of these versions and it didn't work out. Maybe I put it in the wrong place and the code itself works. Can you tell me where I have to put some of these <input type="text" value="myvalue" class="class anotherclass" readonly="readonly" > ? Commented Apr 17, 2020 at 11:07
  • If you have access to the HTML code then edit your answer and show what you've attempted and didn't work - I'll be able to help you better. Commented Apr 17, 2020 at 11:34
  • I basically used the above quote <input .....> and copied it into my script before the </script> tag. I have no idea where to put this. The code I posted initially is all I got till now. What do you mean with access HTML? Should I make a new block under </script> and put it in there? But then it won't relate to the stuff in <script> </script> block or am I wrong? Commented Apr 17, 2020 at 12:35
  • No, that code wouldn't go between your <script></script> tag - JavaScript code goes between those tag, <input ... /> code between your <body></body> tag. Commented Apr 17, 2020 at 12:38

1 Answer 1

0

  <input type="text"  value="static value" readonly>

you can do this with read only property it prevent the all type of changing

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your reply, it turned out I need to use Javascript in my code to get that readonly feature since I can't edit HTML there as I expected. So I'm at the very beginning again.
@Schmiddi then you should try this one; document.getElementById("myText").readOnly = true;
Sorry for my late answer, but this doesn't work either. Dunno why or what I'll be missing but seems like I cannot access this field. Question is, why I can set a default value in there.
for default value just pass variable to value like value={data.value}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.