Ticket #6331 (closed bug: worksforme)
BUG on Setting value to hidden input
| Reported by: | jennal | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.4.3 |
| Component: | manipulation | Version: | 1.4.2 |
| Keywords: | val | Cc: | |
| Blocking: | Blocked by: |
Description
I try to set a long html to a input:text, it is ok. But when I set the input to hidden, then set the same html value to it. The input gone.
Please see attach.
Attachments
Change History
comment:1 Changed 3 years ago by addyosmani
- Priority set to undecided
- Status changed from new to closed
- Resolution set to worksforme
I've tested the above bug in Safari and FireFox (latest builds) and it would appear that a few things are going on here:
- Your test to establish whether the value of the long piece of text/html being set to the input field value is incorrect.
Rather than checking the length of the input field itself, you want to be checking the length of $('#test').val().length instead.
This will give you a value of over 2000 rather than the value of 1 you were previously getting.
- Using $('#test').val() once you have set your hidden field's value, you are easily able to re-use the value set (I was able to alert the entire html/text string without any trouble at all).
Closing as this works for me. I think it was just a case of the original submission testing for attribute lengths in the wrong way.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

