Skip to content

Instantly share code, notes, and snippets.

@x43x61x69
Created April 9, 2018 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x43x61x69/1f152d83514f5a328dd8d3af044883e0 to your computer and use it in GitHub Desktop.
Save x43x61x69/1f152d83514f5a328dd8d3af044883e0 to your computer and use it in GitHub Desktop.
javascript:
{
function evtSim(e, idx)
{
sel.selectedIndex = idx;
var evt = document.createEvent("MouseEvents");
evt.initEvent("change", false, true);
e.dispatchEvent(evt);
}
function inj(plt)
{
if (plt != null)
{
sel = document.getElementById('mygogoro-plate');
var opts = sel.options;
for (var opt, j = 0; opt = opts[j]; j++)
{
if (opt.value == plt)
{
evtSim(sel, j);
return;
}
}
var nopt = document.createElement('option');
nopt.value = plt;
nopt.innerHTML = plt;
sel.appendChild(nopt);
evtSim(sel, sel.length - 1);
}
}
var plt = prompt("車牌號碼 (例:ABC-1234):", "");
inj(plt);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment