I have this dropdown below which I have taken out of the actual page I need to work on at http://www.howtoclone.co.uk.gridhosted.co.uk/plasmid-builder where I pass the product ID value from another page to the jquery below to preselect the dropdown 'value'. When I just run this below in isolation it works.
<select name="0product_id[]" class="groupSelect" id="groupsel_0" onchange="productbuilder.update(this.value,0);">
<option value="0" class="notag" id="id0_0">--Select--</option>
<option class="notag" value="338" id="id0_338" >Dual Promoter Puromycin Expression Plasmid - pSF-CMV-PGK-Puro > £114.00</option>
<option class="notag" value="282" id="id0_282" >EMCV IRES Puromycin Expression Plasmid - pSF-CMV-EMCV-Puro > £114.00</option>
<option class="notag" value="265" id="id0_265" >FMDV IRES Puromycin Expression Plasmid - pSF-CMV-FMDV-Puro > £114.00</option>
<option class="notag" value="101" id="id0_101" >Puromycin Selection Plasmid - pSF-CMV-Ub-Puro AscI > £114.00</option>
<option class="notag" value="105" id="id0_105" >Puromycin Selection SV40 Ori Plasmid - pSF-CMV-Ub-Puro-SV40 Ori SbfI > £114.00</option>
<option class="notag" value="323" id="id0_323" >Rous Sarcoma Virus Promoter Puromycin Expression Plasmid - pSF-CMV-RSV-Puro > £114.00</option>
</select>
and This is the snippet which works to change the value on load:
<script>
$( document ).ready(function() {
$("#groupsel_0 option[value=105]").attr("selected", "selected");
});
</script>
As soon as I upload it to the site it has no effect. Can anyone help?
If you know the value, why not just set it:
$( document ).ready(function() {
$("#groupsel_0").val("105");
});
FIDDLE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With