OK thats easy just google "javscript form input value", the first one that came up for me was http://www.javascript-coder.com/javascr ... alue.phtml
Bill
AJAX example question to fill form fields
Re: AJAX example question to fill form fields
Just so I don't give you irrelevant or redundant advice can you confirm that you're using The Ajax Version 2 framework that I wrote and that you watched the video that was linked from there?
Re: AJAX example question to fill form fields
Yes, I did use the AJAX version 2 referenced in the web video. It's all being done using the JSON objects and your code with minimal changes at this point to basically just shove in all the variables I needed pushed back through Ajax.
Thanks!
Scott
Thanks!
Scott
Re: AJAX example question to fill form fields
It sounds like you might just be stuck on the syntax for a form element. So assume your Brightness field has an ID tag of "myBrightness" you just get the node via the id and set the value property. Since you're using Prototype you can use this
There are also other ways to get to form elements via Javascript, something like "document.form[fieldname].value =" for one, but I tend to put unique ID tags on everythng to make my life easy.
[EDIT]
I am assuming your Ajax request is specifying a handler to process the JSON object once it comes back. Using the video example at around 4:30 you'll see that I'm in my handler shell.CreateSampleData, inside the if where I check that the JSON object isn't null, you'll see me using syn.AddTextToCleanNodeViaId(). You should have something similar; you just want to use the above code for setting the field value instead of adding text to a node.
A couple of general pieces of advice. jsfiddle can be very useful for messing around with snippets of javascript code. Stackoverflow can get you answers to JavaScript questions within minutes. Make sure you search first, most programming questions in the known universe have already been asked and answered. If I don't find an answer from a search, I start asking the question, BUT, before I submit I look at all the suggestions for answers that StackOverflow provides. It's perfectly OK to ask your question here too, but you should expect slower response times.
Code: Select all
$("myBrightness").value = yourJsonObject.brightness;
[EDIT]
I am assuming your Ajax request is specifying a handler to process the JSON object once it comes back. Using the video example at around 4:30 you'll see that I'm in my handler shell.CreateSampleData, inside the if where I check that the JSON object isn't null, you'll see me using syn.AddTextToCleanNodeViaId(). You should have something similar; you just want to use the above code for setting the field value instead of adding text to a node.
A couple of general pieces of advice. jsfiddle can be very useful for messing around with snippets of javascript code. Stackoverflow can get you answers to JavaScript questions within minutes. Make sure you search first, most programming questions in the known universe have already been asked and answered. If I don't find an answer from a search, I start asking the question, BUT, before I submit I look at all the suggestions for answers that StackOverflow provides. It's perfectly OK to ask your question here too, but you should expect slower response times.