Note that there are some explanatory texts on larger screens.

plurals
  1. POChange input value to jquery object
    text
    copied!<p>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.</p> <pre><code>&lt;script&gt; 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); }); } &lt;/script&gt; </code></pre> <p>HTML:</p> <pre><code>&lt;form action="preview.php" method="post"&gt; Action: &lt;select name="whichslide" onchange="schedule(this.value)"&gt; &lt;option value="ab"&gt;Add &amp; Bump&lt;/option&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;option value="4"&gt;4&lt;/option&gt; &lt;option value="5"&gt;5&lt;/option&gt; &lt;option value="6"&gt;6&lt;/option&gt;&lt;/select&gt;&lt;br /&gt; Year: &lt;input type="text" name="year" size="3"&gt; &lt;br&gt; URL: &lt;input type="text" name="url" size="35"&gt; &lt;br&gt; Description: &lt;input type="text" name="description" id="fvdescription" size="75" value="Description goes here"&gt; &lt;br&gt; &lt;input type="submit" name="preview" value="Preview"&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload