1

This might sound trivial but I require passing an argument through an onChange() method that I have created on a dynamic combo-box selection.

Method within which the Combobox is created

function createWhereClauseForm(elementID, fromNameSt,attributesNameArray,attributesDataTypeArray)   
{
   ...
   var attributesListed = '<select id="WhereAttributeCombo" onChange = "getSelectedAttribute($elementID)"><option value="voidopt">Select an attribute</option>';
   ...
}

This is what I've currently done passing the elementID using $elementID. But it does not work.

Any suggestions on how I could pass this elementID to the getSelectedAttribute method within the same script will be much appreciated.

1
  • 1
    var attributesListed = '<select id="WhereAttributeCombo" onChange = "getSelectedAttribute(' +elementID+')"><option value="voidopt">Select an attribute</option>' Commented Jul 18, 2017 at 6:42

2 Answers 2

1

You need to put the variable outside of the string.

... getSelectedAttribute(' + elementID + ')"><option ...
//                       ^^^^^^^^^^^^^^^^^

Complete line:

var attributesListed = '<select id="WhereAttributeCombo" onChange = "getSelectedAttribute(' + elementID + ')"><option value="voidopt">Select an attribute</option>';
//                                                                                          ^^^^^^^^^^^^^
Sign up to request clarification or add additional context in comments.

Comments

1

Currently you pass elementID as an string. You have to pass like

var attributesListed = '<select id="WhereAttributeCombo" onChange = "getSelectedAttribute(' + elementID +')"><option value="voidopt">Select an attribute</option>';

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.