I have looked at the documentation at http://www.web2py.com/books/default/chapter/29/05/the-views?search=OPTION%28 and I have looked at the previous question How to preselect options in SELECT helper in web2py, but my selects have not been working properly.
I make the select:
select = SELECT(_name = attr)
I populate it by appending options in a loop
...
option = OPTION(the_string, _value=str(row.id))
select.append(option)
...
I set the selected value for the select
select.value = str(selected_value)
But the select does not have anything pre-selected. In the html, the correct option is not marked 'selected'. What am I missing?
value is an argument of SELECT.__init__ -- it is not an attribute that can simply be set after the object is created. If you want to change the selected attribute of an option after it has been created, you can do:
select.element('option[value=%s]' %
str(selected_value))['_selected'] = str(selected_value)
Or just specify the selected option when creating the OPTION object:
OPTION(the_string, _value=row.id, _selected=True)
Related
I have a select tag with some options under it . I select one value out of those along with other field values and move to next page. Once I return to previous page I want to check whether the dropdown value is same as that I selected. How can I get the already selected value using protractor. Can someone please help.
Following #Grasshopper's comment, I read this, and the following worked for me:
expect(element(by.xxxxxx('xxxxxxx')).$('option:checked').getText()).toEqual('xxxxxx')
var dropdownval=element(by.xpath/css("Xpathofdropdown/cssofdropdown")).element(by.css('option:checked')).getText();
console.log(dropdownval);
The following code helps me to resolve the issue,now the variable contains the value of the dropdown selected
var dropdownval=element(by.xpath("XpathOfDropdown")).element(by.css('option:checked')).getText();
console.log(dropdownval);
First select the input, then select the option using css, with the option:selected tag:
var selected = element(by.css('#ID_OF_THE_SELECT option:selected'))
Can anyone suggest a link or solution to add select All option within the multiselect dom element of the material design. I want all the options to be selected except for the select all option and want to display it in the text field and post it.
I couldn't find a solution for it. Can anyone suggest.
Pls Note: I dont want to add it as a button outside the dom.
$("#all_member").change(function(){
if($("#all_member option[value=-1]:selected").length > 0){
$('#all_member option').attr('selected', "selected");
$('#all_member').prev("ul").find("li").addClass('active');
$('#all_member').prev("ul").find("li span input").attr('checked', "true");
}else{
$('#all_member option').attr('selected', "false");
$('#all_member').prev("ul").find("li").removeClass('active');
$('#all_member').prev("ul").find("li span input").removeAttr('checked');
}
Thanks IN advance!
I can provide the logic. The rest is up to you.
Put an onChange event handler (function) for your select.
On that function, put an "if statement" to check if the value is equal to the value of "Select All" option.
If it returns true, then manually call the element and set its value to the value of all the other options (probably an array).
I'm trying to select the second option in a <select> tag with the DOMCcrawler. First of all, I select the second form in the page:
$form = $DOMCrawler->filter('form')->eq(1)->filter('input[type=submit]')->form();
Then I could change each value of the form by:
$form['value'] = "new value";
but I don't have a fixed key for each value. Instead, I have a variable number. E.g. I could have something like:
$form[1234];
but also could be
$form[4321];
depending on other variables. So I need to change the form values without knowing the key values, but its position in the node <form>. E.g. something like $form->firstKey();
Also, I want to select the second option inside <select> tag, not a fixed value. Any ideas on how to achieve it?
I am trying to tick a check box on a form when I select one of many combobox values that begins with (REF) - this is code that stands for Referral closure.
this is what I've done..it's not working
Private Sub ReasonForInappriopriateReferral_AfterUpdate()
If Me.RsnForInappropriateRef.Value Like "(REF)*" Then
Me.Check66 = True
End If
End Sub
Please help, I was previously trying to conditional format a label to a different colour if the closure reason was a Referral closure, but couldn't do that either and think it could be down to the IF Like command.
I added two controls exactly as you indicated. I populated my combo by setting the Row Source Type to a Value List, and the Row Source to "Blah Blah";"(REF) - Jackson";"Two Times";"(REF) - Tyson"
I put this in the Click event of a button:
If Me.RsnForInappropriateRef.Value Like "(REF)*" Then
Me.Check66 = True
Else
Me.Check66 = False
End If
it behaved exactly as expected. I then moved it to the AfterUpdate event of the combobox, and again it worked flawlessly. The only thing I can see is that in your example, the combobox does not have the same name as your sub (ReasonForInappriopriateReferral vs RsnForInappropriateRef). Are you sure your names are right?
I need for my select lists to have a default option of an empty value, or "Select" with no value.
I don't see any mention of how to do this in the documentation.
// $Id: webform.module,v 1.196.2.47 2010/08/16 17:54:19 quicksketch Exp $
You can add the patch webform_select_none_0.patch as mentioned in http://drupal.org/node/563170. Or if you do not have any experience with patches, you can add the following code to the _webform_render_select function in /sites/all/modules/webform/components/select.inc (of course taking into account any disadvantages of manually editing code)
if ($component['extra']['aslist'] && !$component['extra']['multiple'] && ($default_value === '' || !$component['mandatory'])) {
$element['#empty_value'] = '';
}
This will add the - Select - option to mandatory webform select fields when no option is selected
On the webform controls tab (node/%/edit/components/%), all you need to do is uncheck the "Mandatory" checkbox under "Advanced Settings".
Create a custom module and use form alter to modify the output. Explained here: https://www.drupal.org/node/1331956#comment-5876808
I believe you can achieve this with an empty entry in your option list:
|--Choose one--
val1|Value 1
val2|Value 2
val3|Value 3
etcetera.
However, I can't seem to find any sources on this at the moment. Good luck!