2

Good day,

I am using the plugin selectize for my projects select elements, it looks good and simple but I just want to ask if how do I make the option list become links to other pages?

heres my simple html code

<div class="control-group">
                <label for="sreport-select">Search:</label>
                <select id="report-select" class="demo-default" placeholder="Select Report">
                    <option value="">Select Report</option>
                    <option value="4"><a href="home">Profit and Loss</a></option>
                    <option value="1"><a href="link">Balance Sheet</a></option>
                    <option value="2"><a href="test">Expenses</a></option>
                </select>
            </div>

and my js

<script>
  $('#report-select').selectize({
  create: false,
  sortField: {
  field: 'text',
  direction: 'asc'
 }
</script>

I did tried adding some on option list but nothing is happening. Any information or suggestion would really be appreciated! Thanks and have a Good day!

1 Answer 1

2

You could try something like this:

<div class="control-group">
<label for="sreport-select">Search:</label>
<select id="report-select" class="demo-default" placeholder="Select Report">
    <option value="">Select Report</option>
    <option value="home">Profit and Loss</option>
    <option value="link">Balance Sheet</option>
    <option value="test">Expenses</option>
</select>

And add this to your javascript:

$('#report-select').change(function(){
    if ( $(this).val() !== '' ) {
        window.open($(this).val(), '_self');
    }
});

This simulates a link click in javascript, so you won't actually need links in your select group.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.