Jump to content

JS problem-populating one dropdown based on selections


Recommended Posts

I am trying to populate one drop down based on multiple dropdown selections before it in virtual fields in javascript. My code looks like this:

<script type="text/javascript">

function createIt()
{
var mke = document.getElementById('EditRecordMake').value;
var mdl = document.getElementById('EditRecordModel').value;
var ps = document.getElementById('cbParamVirtual1').value;
var sys = document.getElementById('cbParamVirtual2').value;
var ct = document.getElementById('cbParamVirtual11').value;
var bkl = document.getElementById('cbParamVirtual6').value;
var key = document.getElementById('cbParamVirtual12').value;
var rpm = document.getElementById('cbParamVirtual16').value;
var hyd = document.getElementById('cbParamVirtual17').value;
var pkbk = document.getElementById('cbParamVirtual13').value;
var spd = document.getElementById('cbParamVirtual7').value;
var optn = document.getElementById('cbParamVirtual14').value;
var wu = document.getElementById('cbParamVirtual4').value;
var cc = document.getElementById('cbParamVirtual5').value;
var idread = document.getElementById('cbParamVirtual8').value;

var mycode = document.getElementsByTagName('select')[17];

var codeval = mke + "_" + ps + "_" + mdl + "_" + sys  + ct + bkl + key + rpm + hyd + pkbk + spd + optn + wu + cc + idread;

var codetxt = mke + "_" + ps + "_" + mdl + "_" + sys  + ct + bkl + key + rpm + hyd + pkbk + spd + optn + wu + cc + idread;

mycode.options[0] = new Option(codetxt, codeval, false, true);
//mycode.option[mycode.length] = new Option(codetxt, codeval, false, true);

}

document.getElementById('cbParamVirtual1').onchange = createIt;
document.getElementById('cbParamVirtual2').onchange = createIt;
document.getElementById('cbParamVirtual11').onchange = createIt;
document.getElementById('cbParamVirtual6').onchange = createIt;
document.getElementById('cbParamVirtual12').onchange = createIt;
document.getElementById('cbParamVirtual16').onchange = createIt;
document.getElementById('cbParamVirtual17').onchange = createIt;
document.getElementById('cbParamVirtual13').onchange = createIt;
document.getElementById('cbParamVirtual7').onchange = createIt;
document.getElementById('cbParamVirtual14').onchange = createIt;
document.getElementById('cbParamVirtual4').onchange = createIt;
document.getElementById('cbParamVirtual15').onchange = createIt;
document.getElementById('cbParamVirtual8').onchange = createIt;
document.getElementById('EditRecordMake').onchange = createIt;
document.getElementById('EditRecordModel').onchange = createIt;

</script>

It is not working. Could anyone offer any insight as to why please? Anything would be much appreciated!

Link to comment
Share on other sites

  • 8 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...