Jump to content

addoption syntax


Recommended Posts

I am trying to adapt some code I found online and I don't understand one (actually more) of the lines of code.

The code is from a function to generate dropdown lists that depend on previous dropdown lists.

The line says "echo "addOption(document.drop_list.Category, '$nt1[cat_id]', '$nt1[category]');";"

What does the $nt1 mean and why are there two different values for it?

Can someone explain this to me in novice language?

I can't find any reference to addOption in the Javascript reference.

I'm trying to substitute my table fields into the code, but can't figure out which goes where.




Link to comment
Share on other sites

$nt1 is a PHP associative array, not a Javascript array. Read about it here: https://www.w3schools.com/php/php_arrays.asp

The code you've displayed is a line of PHP that's generating a line of Javascript, you need to be able to distinguish which parts are PHP and quich are Javascript. The addOption function is probably declared elsewhere in the code.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...