Well, I figured out how to return my results and save the value in my code, so nothing breaks here, as I did.
$(document).ready(function() { $('#Exposures').bind('change', function() { var elements = $('div.exposures').children().hide(); // hide all the elements var value = $(this).val(); *added* var exposuredd = document.getElementById("Exposures"); *added* var selectedText = exposuredd.options[exposuredd.selectedIndex].text; *added* document.getElementById("exp1").innerHTML="<input type='text' name='exposures_pt1' value='"+selectedText+"' >"; if (value.length) { // if somethings' selected elements.filter('.' + value).show(); // show the ones we want } }).trigger('change'); $('.second-level-select').bind('change', function() { var elements = $('div.second-level-container').children().hide(); // hide all the elements var value = $(this).val(); if (value.length) { // if somethings' selected elements.filter('.' + value).show(); // show the ones we want } }).trigger('change'); });
it should be in erb im using this in
<p hidden id="exp1"></p>
So, now I can transfer any text in my versions to ruby, for example ... "Hey, here I am"
<option value="1">Hey Here I am</option>
source share