PDA

View Full Version : Select prefix by jQuery


BulliM
02-15-2018, 06:47 AM
I need help in selecting a default prefix on creating new topic. Selected by default is "No Prefix". In our support forums I want to change it to prefixid "unsolved" by default.

Normally I would select the right option by attribute, but that don't work, because source code is different after js-rollup. Seems all options were change into span tags. I don't really have any idea, how to select and submit the needed value to change dropdown menu (selected=selected). Can someone help me?

--------------- Added 1518688013 at 1518688013 ---------------

I now have a solution for selecting "Unsolved" prefixid value. But dropdown furthermore displays "No Prefix".

How can I set that to "Unsolved" ?

Here is my code so far:

if($("div[data-current-channelid*='23']").length == '1') {$('.js-content-entry-prefixes option[value="Unsolved"]').prop('selected', true);}

delicjous
02-15-2018, 10:19 AM
Perhaps something like this:

$('.js-content-entry-prefixes .selectBox-label').text('Unsolved');

Did not test it!

BulliM
02-15-2018, 10:33 AM
Perhaps something like this:

$('.js-content-entry-prefixes .selectBox-label').text('Unsolved');

Did not test it!

This works:
$('.selectBox-label').first().html('Unsolved');

Danke dir delicious!

Final Code:
if($("div[data-current-channelid*='23']").length == '1'){$('.js-content-entry-prefixes option[value="Unsolved"]').prop('selected', true);$('.selectBox-label').first().html('Unsolved');}