Bug Tracker

Opened 14 years ago

Closed 13 years ago

#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:
Blocked by: Blocking:


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 (1)

test2.html (2.5 KB) - added by jennal 14 years ago.

Download all attachments as: .zip

Change History (2)

Changed 14 years ago by jennal

Attachment: test2.html added

comment:1 Changed 13 years ago by addyosmani

Priority: undecided
Resolution: worksforme
Status: newclosed

I've tested the above bug in Safari and FireFox (latest builds) and it would appear that a few things are going on here:

  1. 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.

  1. 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.

Note: See TracTickets for help on using tickets.