ajax auto checkbox


i have a select box with some options in and i want to be able to have my ajax replace the value in the options with a value i get from the upload.php

if i use this in the function

document.getElementById(transmission').options[1] = new Option  ('some value');

it replaces it but i need it to replace it with the value in the php page where it reads
echo "formObj.transmission.value = '".$transmission."';\n";  

how would i read that value and put it in this

document.getElementById(transmission').options[1] = new Option  ('$transmission');



what shows in my upload.php that the ajax calls
$transmission = 'Leather Seats';
echo "formObj.transmission.value = '".$transmission."';\n";  
my head section
<script type="text/javascript">
		var ajax = new sack();
	var currentvinId=false;
function getvinData()
document.getElementById('transmission').options.value = getvinData;
		var vin = document.getElementById('vin').value;
			currentvinId = vin
			ajax.requestFile = 'upload.php?getvinId='+vin;	// Specifying which file to get
			ajax.onCompletion = showvinData;	// Specify function that will be executed after file has been found
			ajax.runAJAX();		// Execute AJAX function			
	function showvinData()
		var formObj = document.forms['addlisting'];	
	function initFormEvents()
		document.getElementById('vin').onblur = getvinData;
	window.onload = initFormEvents;
body section
<select id="transmission" name="transmission" size="1"><option value="Automatic">Automatic</option><option value="Manual">Manual</option><option value="Dual">Dual</option></select>

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The way you are doing it now, it would be done by changing

echo "formObj.transmission.value = '".$transmission."';\n";  

in the php file to

echo "document.getElementById(transmission').options[1] = new Option  ('" . $transmission . "');"
petecrane99Author Commented:


i used

echo "formObj.transmission.options[0] = new Option  ('".$transmission."');\n";

and that worked which is great how easy would it be to do with check boxes?
petecrane99Author Commented:
this is my checkbox's

<input value="Leather Seats" id="standfeatures" name="standfeatures[8]" type="checkbox">Leather Seats</td>
Same thing. The php is generating a javascript code line that is executed on the client browser. So you wanted to have a javascript

document.getElementById('transmission').options[1] = new Option  ('some value');

and the php code had

echo "formObj.transmission.options[0] = new Option  ('".$transmission."');\n";

Similarly, it can be done for any other javascript code that you want. So for checkbox assuming that you have unique id, you would need

document.getElementById('standfeatures').checked = true;

in php just echo the above string. But if you don't have unique id (standfeatures) and want to loop through the set of checkboxes, the code would be different. If you give more details, we can help you in that too.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CWS (haripriya)Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.