I have a form with two inputs. The first one is a regular text input. The second one is a text inpu side by side with a dropdown menu list.
Once the first input is entered, the user should enter a number into the second input. The second input is essentially a sublist of numbers available under the first selected input number (think of it as a multidimensional array).
Once the onFocus
or onChange
is set to the second input I want to execute a the onfocus
/onChange
JavaScript functions and make them run a perl script. The results of the perl script should populate the dropdown list - so the user essentially will be able to select or type in the number they wish to choose.
I found this in order to make a call to a PHP function - but my function accepts only one variable and after I modified it I get or the default result or `No function arguments'
What would be the right way to execute a perl script from a JS function and then get the perl results and populate in the HTML? (I know it is broad, but a direction would be nice, and example would be great)
Before answering I'll make some assumptions explicit:
This said, in the Javascript code on the client-side you basically don't care which programming language is answering on the server side. You have to decide where your server will answer - e.g. on "/list2-alternatives/" - and assuming that you only want to pass one single "simple" parameter, you can encode it directly in the URI (e.g. "/list2-alternatives/XXX" and "/list2-alternatives/YYY" depending on what comes from the first field). This goes for the client side.
On the server side, you will have to ensure that the particular path returns the data you're after.
This is what will happen:
http://your-server/list2-alternatives/whatever
to the server