[Solved] I need to get text box question to display as read only



This is about project 2495936. My situation is that I have a survey with imported data. I want to make the imported stuff read only so people can only review it as they respond. I followed the instructions at the page below but I was not successful in getting a text box field to display as read only.


For every other type of variable on the page except text box, it says you need to add the element ID. Is this code missing from the text box example? I tried to identify then in the attached screen shot but I am not sure what to do with these element IDs.

Any suggestions.

Frank Smit asked

    Best answer


    Hi Frank!

    The textbox example from that tutorial does not require an ID, because that specific example is targeting all textboxes on a page.

    To target a specific textbox, you may simply prepend that textbox’s ID to the “input:text” selector, with a space in between. To target additional specific textboxes, you may repeat line two of the script:

    function readOnly() {
      $("#sgE-1234567-1-10-box input:text").attr("readonly", true);
      $("#sgE-1234567-1-11-box input:text").attr("readonly", true);
      $("#sgE-1234567-1-12-box input:text").attr("readonly", true);
      /* ... and so on */
    $(readOnly) /*This executes the above function when the page (or DOM) is ready*/

    When experiencing trouble with a piece of Javascript, your best bet is to check in the Console for any Javascript errors. If you see no errors listed, it may be a good idea to ensure you’ve placed your Javascript code in the correct place (in a Javascript action), otherwise it might not be getting “interpreted” by the web browser as Javascript code.

    If you do see errors, first do a web search for the error you received — chances are, you’re not the first person who’s had that error, and resources such as Stackoverflow.com can be an amazing help in these situations.

    I hope this helps!

    Nathan - Survey Astronaut answered


      Question stats

      • Active
      • Views2931 times
      • Answers1 answer
      • Followers0 followers