I have a dropdown with 4 options. I want these options to be prepopulated depending on value that is selected from a different field. The different field is a "countries" field.
If country "A" or country "b" is selected, I want the dropdown to populate option 1.
If a different country, populate option 2.
Thanks in advance
You can try the following:
Find which event is fired when a user change the first dropdown value
Register a function to this event
In this function, detect what is the new input from the first dropdown. Check it, and change the value of the second dropdown depending on this check (How do I programmatically set the value of a select box element using JavaScript? could be useful for the implementation)
If you have issue trying to do it, do not hesitate to ask :)
Related
I have a form I created in pdf that basically has a dropdown with the student's names that uses their Student ID's as the values. Pretty straightforward. I am able to populate another field (textbox) with the value of the selected item in the dropdown. Works great. I have searched in whatever ways I know how, but I am unable to find an answer to this question:
I have a second dropdown that I very simply want to populate with the same selected index as the first. In other words the selected indexes of both dropdowns will always match each other (I don't need a two way function, I just want the second dropdown to match the first.). I don't know of a way to assign two values to each dropdown item or I would try that. In theory, this problem seems like it should be really simple to solve, but I guess that's what makes me, me.
Here is the simple code I use to get the value from the dropdown and populate the textbox:
event.value = this.getField("Fieldname").value;
Thank you.
After much experimentation, I finally realized there actually IS a simple way to do this. Let me try to explain. The first dropdown has student names using their student ID's as the VALUES. The ID text box pulls the values from the selected name to display the id number. I needed the third dropdown field to display the address. Here's how simple that was:
I called the value from the textbox (which was the student ID). I set up the third dropbdown to have the address as the display and the Student ID as the VALUE of the address. I then just set it up like the iroginal:
event.value = this.getField("Fieldname").value;
Voila! It now displays the address in the third field.
It seems like you can actually daisy chain this method repeatedly to autofill even more fields if you needed to.
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' $$)
My problem is I have to create a form using Domino Designer, which contains a field with a combobox. That combobox has a list of a column in a view. Next to this field is a another that was the price of the product selected in the combobox, and this price came for the same view.
The second field must be computed, and you need to use the #DbLookup function in it's formula. You also need to set the property Refresh fields on keyword change for the combobox field.
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!
I have an HTML select element (combo box) in a form with a couple if options in it. As always each option has a specific value. During the page's initialization I get a value from the server that I must use as the selected option in the list. Sometimes however I get a value from the server that does not match any of the available options. (grrrr)
I want to let the user know that the value I got from the server is not a valid option. What I'd like to do is show an empty select box (as if no selection was made) without having an actual empty option as one of the options. Also I'd like to use the default select element if possible. Is something like this possible?
Edit: When you set the value for a combox to '' in IE9 (I used $('select').val('') ) it empties the text in the combo box which is exactly what I need. Unfortunately only IE9 does this, so this is not an option.
Out of the box, HTML selects do not provide such functionality. You will have to add an empty <option value="somethingwrong">Please, pick a value</option> element and use scripting to check if the user has selected this specific value. I'd suggest catching both onchange event of the dropdown and onsubmit event of whole form.
You can insert option in select, and remove that whenever it is changed to reduce problems with that options
Check the Demo here