add html content to hidden form field

Is it possible to pass a chunk of html content to a hidden field and how would I do this?




Yes - simply HTML encode the content (e.g. replace "<" with "&lt" etc...)

You didn't specify which language you'll use for poplulating the field value, so I can't help with details of how to encode.

Here's a reference of how to do it in jQuery.

Here's Java

You could do this with Javascript:

<input type="hidden" id="htmlCodes" />
document.getElementById("htmlCodes").value = "<strong>Hello World</strong>";

Just be sure that your values are properly-escaped when you pass them into the hidden form field.

Online Demo:

You can also "spawn" a hidden textarea after processing the content inside.

This can be done easily with Jquery :

.append('<textarea name="content" class="hidden">' + your_content + '</textarea>');

Here we assuming that you've got a "hidden" class, Bootstrap's got one, but you can also use this :

CSS Code :

  display: none !important ; 
  visibility: hidden !important; 

Need Your Help

Hibernate many-to-many mapping not saved in pivot table

java hibernate multithreading annotations pojo

I having problems saving many to many relationships to a pivot table.

Update fixture column not working in case of ThinkingSphinx

ruby-on-rails thinking-sphinx

I am writing thinking-Sphinx test cases. i have following test case