ColdFusion makes it simple to populate a form fiel...
# javascript
ColdFusion makes it simple to populate a form field with a previously submitted value: <input name="myVar" value="#form.myVar#"> Q: How do I do the same using JavaScript? If the values were in the url scope, I could use window.location.href, but they're in the form scope instead.
I don't believe JS knows about the form scope; you'd have to load them into a JS variable ahead of time.
I have to believe it has something to do with the FormData object, but I haven't figured it out yet.
Yeah, I got into express body-parser and tapped out.
Items sent with FormData() can be found in the form scope, but JS can't directly access the CF form scope. You could probably use the FormData() object to set input values. But it's hard to tell without seeing how you are attempting to do this.
If we were running node.js:
Copy code
server = http.createServer(function(request, response) {
var data = '' request.on('data',function(chunk) { data += chunk; }) request.on('end', function() { console.log(JSON.parse(data).todo); // 'Buy the milk' response.end(); }) }) `````` But I'm not.
Are you sending your form with
or just a regular form submit?
<input id="anId" ...>
document.getElementById('anId').value = "#form.myVar#"