I have a CloudPage form which contains a Select Dropdown with a JSON-esque Value:
<select id="Select_Specialism" name="Select_Specialism" required=""><option value="">Select Specialism</option>
<option value="{'FileName':'Accounting','PDFURL':'http://CLIENTURL/lib/43244fdsffdsf/m/1/account.pdf'}">Accountancy & Finance</option>
<option value="{'FileName':'Banking','PDFURL':'http://CLIENTURL/lib/43244fdsffdsf/m/1/banking.pdf'}">Banking & Financial Markets</option> </select>
The form is submitted to a Processor CloudPage, which is SSJS :
var specialism = Request.GetFormField("Select_Specialism");
try {
var obj = JSON.parse(specialism); // this is how you parse a string into JSON
Write(Stringify(obj));
var PDFDownloadLink = obj.FileName;
var PDFFileName = obj.PDFURL;
} catch (ex) {
Write(Stringify(ex));
}
I'm wanting to set PDFDownloadLink and PDFFileName from the Select value passed as JSON, however when I run this, I get a 500 Internal Server Error
(there is a further process for logging to data extension and redirecting to PDF URL, but if PDFDownloadLink and PDFFileName are hardcoded with the values then it works)
Any observations of where I might be going wrong is appreciated.