So I would like a similar function however my issue is that I am trying to use this code on 2 pages so when a button or link pressed. it will automatically set the <option>
as the option that is selected on the other page.
https://jsfiddle.net/8RUBj/15/ (similar to this)
$('.select-change').click(function() {
$('#City').val($(this).data('val')).trigger('change');
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
<div data-role="page" id="page12">
<div data-theme="e" data-role="header">
<a href="#page1" data-icon="back" data-transition="flow" data-direction="reverse" data-ajax="false">Back</a>
<h3>
jQuery Mobile App
</h3>
</div>
<div data-role="content">
<label for="City">Select City</label>
<select name="City" id="City">
<option value="">Select city...</option>
<option value="A">Auckland</option>
<option value="W">Wellington</option>
<option value="C">Christchurch</option>
<option value="Q">Queenstown</option>
<option value="D">Dunedin</option>
</select>
<br>
<div data-role="controlgroup">
<a data-role="button" data-val="A" class="select-change" id="btnAuckland">Auckland</a>
<a data-role="button" data-val="W" class="select-change" id="btnWellington">Wellington</a>
<a data-role="button" data-val="C" class="select-change" id="btnChristchurch">Christchurch</a>
<a data-role="button" data-val="Q" class="select-change" id="btnQueenstown">Queenstown</a>
<a data-role="button" data-val="D" class="select-change" id="btnDunedin">Dunedin</a>
</div>
</div>
<!-- Close Content Div of Page12 -->
</div>
<!-- Close Page12 -->
https://www.youtube.com/watch?v=vOe0ysNsNCo (tried combining this, even though they are two different languages)
I have attempted to to combine another piece of code of how to pass variable from one page to another however no luck. Also I was wondering if jQuery would be the best code to use as I am only using CSS ,HTML, JavaScript and of course don't prefer any more issues adding another language?
Please advise
P.s I do apologise, I am a new coder and still getting my head around using stack-overflow. Otherwise I would have posted the code