How can I make an input field read only but still have it send data back to a form?

后端 未结 7 1297
情书的邮戳
情书的邮戳 2021-01-01 11:22

I have an input field:


7条回答
  •  有刺的猬
    2021-01-01 12:08

    On the assumption you're using a script to create the form, I'd suggest using which will submit the variable with the form, but also use a regular to show the variable to the user. This won't submit the value, obviously, but will make it visible (while the hidden input will submit the value, but not show the value).

    You could also do this with JavaScript:

    var theForm = document.getElementsByTagName('form')[0];
    var inputs = document.getElementsByTagName('input');
    
    for (i=0; i

    Clumsy JS Fiddle demo.

提交回复
热议问题