Is there something else I can use on a form to get all the elements and their values that won't put them into URL notation? Or is there a quick way to clean up the string returned?
I'm getting this returned:
filePath=afile.doc&fileTitle=A+File&fileDescription=This+should+be+first+in+an+asc+sort%2C+last+in+a+desc
and would need to clean up the URL stuff for a database submission - (the "+" symbol nad %2C (comma).
Is there a simple way to reverse standard URL-encoded notation?
Is there something else I can use on a form to get all the elements and their values that won't put them into URL notation?
Yes, you can use jQuery's serializeArray
, which will "...Encode a set of form elements as an array of names and values." This would be best, as you avoid doing the encoding in the first place (I take it you want to work with the unencoded version of the values).
Example:
var a, index, entry;
a = $("#theForm").serializeArray();
for (index = 0; index < a.length; ++index) {
entry = a[index];
display("a[" + index + "]: " + entry.name + "=" + entry.value);
}
Live copy
Is there a simple way to reverse standard URL-encoded notation?
Yes. Individual encoded values can be decoded using decodeURIComponent
; a full string of fields can be decoded with decodeURI
.
if you use post instead of query you can name your elements into an array
<input type="hidden" name="block[369][filepath]" value="somepath"/>
<input type="hidden" name="block[369][title]" value="somefile.gif"/>
<input type="hidden" name="block[369][description]" value="imagefile"/>
I'm kind of assuming allot here but this is how I put things into an array for php parsing so I don't have to rely on jQuery to serialize
just an idea
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With