Dynamic list creation using extra button - javascript

I want to create a dynamic list.
It can be select option or dropdown or any other list type.
I want to be able to add new options if the current list does not include the desired option.
I want to use a separate button which pops up a new field which allows the user to add a new value to the list.
How can I do that?
The blue coloured part of this picture shows some code which is producing a pop up in background

use jquery
give a class name to your select and input box and to button then
$(".your button class").click(function(){
var op=$(".your input class").val();
var data="<option>"+op+"</option>";
$(".your select class").append(data);
});

Related

Change source of image field with javascript in Adobe Acrobat

I have a listbox in an Adobe Acrobat form. When I change the value of the listbox, the source of the image field has to be changed with a javascript script:
As a first step, I tried to change the src in javascript, so not yet with the listbox:
var logo = this.getField("companylogo"); // button field
logo.buttonImportIcon("C:\Users\VincentJanssens\Downloads\Blauw.png")
But even this code isn't working.
Thank you for getting me started!
The code can be very simple if you set the fields up to allow for that. The first step is to create buttons for each of the images you want to be available. Name these buttons such that the Export Value of the item in the Dropdown matches exactly. Set these buttons to Hidden and Read Only in the General tab.
Then add a button where you want the various images to appear on your form. Set this field to read-only too. Now, set up the Dropdown to Commit the selected value immediately and add the following JavaScript to the Format script of the dropdown. Replace the string 'displayImage' with the name of the button field you placed on your form.
this.getField("displayImage").buttonSetIcon(this.getField(event.target.value).buttonGetIcon())
Now each time the list item changes, the script will run and use the Export Value of the field to get the button icon from the button with the same name as the export value.
I've posted a working example file here.

how to add input fields and dropdown and sub drop down by click on button using javascript or jquery

I am trying to add input fields and one dropdown by click on button,one more thing is if I select dropdown value another sub dropdown should show based on the selected value of first dropdown.
JSFiddle
I was trying to add fields it has done,but remove is not happening and sub dropdown is not happening.
In that case if I select test1 dropdown one more sub dropdown should show below like test11,test12,test13,
if I select test2 dropdown one sub dropdown should show below like test21,test22,test23 like that ..
one important thing is how can insert those data into Mysqli table when we click the submit button.
I did check this link,in that we can do add and remove input fields and insert also done but when I select drop down I am not going get sub drop down.
How we can do that sub drop down .

Autofill an HTML select list

Scenario: I have 5 select boxes that hold the 5 weekdays and Instead of having the user click and choose a value for each one I want them to have the option of choosing the first box and have a button next to it that when clicked it auto fills the rest of the select boxes with the same value.
Is it as simple as setting the value of the select boxes equal the the value from the first box? Not sure how to tackle this. Would I also have different IDs and same names for the 5 select boxes or keep them different and apply the value to each option?
Give all the select boxes a class, eg <select class="syncday"> and then have your button's clickhandler do something like
$$("select.syncday").set("value", $$("select.selectday")[0].get("value"))
this takes the 'value' from the first select and applies it to all of them (using mootools' $$)

change form based on drop down menu selection

I'm having trouble finding javascript, HTML and/or CSS code that'll change the form based on the drop down menu. For example, the form is for adding a property and the drop down menu selections are single family, condo, apartment but they each have their own set of text boxes, menus and radio buttons. How can I achieve this?
What I have understand from your query is that , you have a from with some fields and you have a dropdown and you want that when ever your change selection in dropdown the form fields values must change accordingly right ?
If that is the issue , then it is very simple , first catch onSelectionChange event of dropdown and try to get selected value and once you get the selected value fill form fields by accessing them accordingly in a condition.Thanks
So I actually already had a piece of code I was fumbling with (http://jsfiddle.net/CYzsY/) for this question and it looks like its not working for me because its based on jQuery 1.7.1 and I'm linking to 1.10.2 in my code. Will make a new post accordingly. Thanks everyone!

How to change selected item in dropdown via clicking on an image (jquery)

I am using magento, but am far from jquery/javascript
I have a list of images that i want to be able to click and change the corresponding dropdown list selection.
I can have it set up so that select name/value or option value can be attached to each image that corresponds either using class or id. So i just need the basic jquery to input
thanks a million
Say the id of the image is the value of the dropdown item.
$('img').click(function() {
$('#dropdown').val($(this).attr('id'));
});
JsFiddle Example

Categories

Resources