How to get multiple selected values of select box in php?

If you want PHP to treat $_GET[‘select2’] as an array of options just add square brackets to the name of the select element like this: <select name=”select2[]” multiple … Then you can acces the array in your PHP script <?php header(“Content-Type: text/plain”); foreach ($_GET[‘select2’] as $selectedOption) echo $selectedOption.”\n”; $_GET may be substituted by $_POST depending … Read more

How to create a drop-down list?

simple / elegant / how I do it: Preview: XML: <Spinner android:id=”@+id/spinner1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@android:drawable/btn_dropdown” android:spinnerMode=”dropdown”/> spinnerMode set to dropdown is androids way to make a dropdown. (https://developer.android.com/reference/android/widget/Spinner#attr_android:spinnerMode) Java: //get the spinner from the xml. Spinner dropdown = findViewById(R.id.spinner1); //create a list of items for the spinner. String[] items = new String[]{“1”, “2”, “three”}; //create … Read more

How do I add options to a DropDownList using jQuery?

Without using any extra plugins, var myOptions = { val1 : ‘text1’, val2 : ‘text2’ }; var mySelect = $(‘#mySelect’); $.each(myOptions, function(val, text) { mySelect.append( $(‘<option></option>’).val(val).html(text) ); }); If you had lots of options, or this code needed to be run very frequently, then you should look into using a DocumentFragment instead of modifying the … Read more