When the user selects from a drop down box, I want to change the value of an input field to a jquery object, which is a span element from another page. This is working fine when I append to #myDiv; the span element shows up. However, I am trying to change a text input value, and this shows "Object object" on select change. I don't understand this inconsistency. How can I get the value to change correctly, as #myDiv does? Thank you.
<script>
function schedule(selectedValue){
var selectedValue = selectedValue - 1;
$.get('/file.xml', function(data)
{
var $slides = $(data).find('span.desctext'),
selectedslide = $slides.eq(selectedValue);
$('#myDiv').append(selectedslide);
$("#fvdescription").val(selectedslide);
});
}
</script>
HTML:
<form action="preview.php" method="post">
Action: <select name="whichslide" onchange="schedule(this.value)">
<option value="ab">Add & Bump</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option></select><br />
Year: <input type="text" name="year" size="3"> <br> URL: <input type="text" name="url" size="35"> <br> Description: <input type="text" name="description" id="fvdescription" size="75" value="Description goes here"> <br>
<input type="submit" name="preview" value="Preview">