Jump to content
pabirds

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.

 

 

 

Share this post


Link to post
Share on other sites

$nt1 is an array

https://www.w3schools.com/js/js_arrays.asp

EDIT:

the info between the commas are arguments

addOption is a function (jquery i think)

Edited by niche

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

$ was the givaway sorry about that.   

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...

×
×
  • Create New...