need to use mootools for simple script instead of jquery... how?
i have a script in jquery (that grabs a value from a select field and transfers it to an input field) that i need to do in mootools...i love jquery... mootools i dont know... not having much luck... here is the code:
<select size="1" class="inputbox select "
id="producers" name="producers">
<option selected="selected" value="">- Select an Article -</option>
<option value="86">Acetaia Leonardi</option>
<option value="50">Esperidia</option>
<option value="49">Frescobaldi Laudemio</option>
<option value="85">Primitivizia</option>
<option va开发者_高级运维lue="87">Principato Lucedio</option>
<option value="51">Rustichella d'Abruzzo</option>
</select>
<input type="text" value="" size="32" maxlength="50"
name="producernamem" id="producernamem"
class="inputbox text required required-enabled">
<!-- [example js] begin -->
<script type="text/javascript">
$(document).ready(function () {
$('#producers').change(function () {
pselected = $('#producers option:selected').text();
$("input#producernamem[type='text']").val(pselected);
alert (pselected);
});
});
</script>
sorry i think i flubbed that by not wrapping the code...
<select size="1" class="inputbox select " id="producers" name="producers"><option selected="selected" value="">- Select an Article -</option><option value="86">Acetaia Leonardi</option><option value="50">Esperidia</option><option value="49">Frescobaldi Laudemio</option><option value="85">Primitivizia</option><option value="87">Principato Lucedio</option><option value="51">Rustichella d'Abruzzo</option></select>
<input type="text" value="" size="32" maxlength="50" name="producernamem" id="producernamem" class="inputbox text required required-enabled">
<!-- [example js] begin -->
<script type="text/javascript">
<!--//<![CDATA[
$(document).ready(function () {
$('#producers').change(function () {
pselected = $('#producers option:selected').text();
$("input#producernamem[type='text']").val(pselected);
alert (pselected);
});
});
//]]>-->
</script>
The MooTools documentation is a good resource for this:
<script type="text/javascript">
window.addEvent('domready', function() {
$('producers').addEvent('change', function(e){
pselected = this.getSelected().get('text');
$("producernamem").set('value', pselected);
alert(pselected)
});
});
</script>
精彩评论