ng-change isn't working for select.(selecting option) (AngularJs) - django

<select class="map-columns" ng-model="col" ng-change="changeValueInExcelData(false, $parent, $index, col)">
<option value="power_market">Power market</option>
<option value="customer">Customer</option>
</select>
Here i have select with option, Now when i change my option ng-change function isn't calling.
I used ng-change with input it worked successfully but I don't know why it isn't working for selection.

Related

Call function through livewire with the value of a custom data-attribute as a parameter

I have a select input which, using livewire, calls a function whenever the selection changes. According to the documentation you can use $event.target.value to get to the selected value, however I want to send a different attribute value (myvalue) to my function.
<!-- this doesnt work -->
<select wire:onchange="myfunction($event.target.dataset.myvalue)">
<option value="1" data-myvalue="12345">
</select>
I got it working using Alpine.js but it seems odd that I need another framework to do so.
<!-- this does work, but requires alpine.js -->
<select x-data='{}' #change="$wire.call('myfunction',$el.options[$el.selectedIndex].dataset.myvalue)">
<option value="1" data-myvalue="12345">
</select>
Is there a pure livewire solution to this?
Your first code snippet is practically there already. The documentation you linked, in which $event is described, even shows why your code snippet doesn't work:
Your code uses wire:onchange, but Livewire checks for wire:change.
With your example though, you could also use wire:model="foo" and hook into the updatedFoo($newValue) function.
See the lifecycle hooks doc

Drop down list select using python selenium (xpath)

Month
<select name="filterMonth" onchange="document.form.submit()">
<option value="0"></option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
How can I select drop down list for "filterMonth" using xpath?
browser.find_element_by_xpath('//*[#id="form"]/table[1]/tbody/tr[3]/td[2]/select[2]')
gives me error that no such element found
You can use the xpath
//select[#name='filterMonth']
if name is unique across the page.
Select select =new Select(driver.findelement(By.xpath("//select[#name='filterMonth']")));
select.selectByVisibleText("January");
This for Java. please change it accordingly for python.
You can try following code:
select = Select(driver.find_element_by_xpath("//select[#name='filterMonth']"))
# select by visible text
select.select_by_visible_text('January')
One of the reasons why you get NoSuchElementException might be using tbody tag in your XPath as this tag not always present in initial HTML source, but might be generated dynamically. The other reason is that entire table could be generated dynamically and you should wait a little to be able to handle it:
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
select = wait(browser, 10).until(EC.presence_of_element_located((By.NAME, "filterMonth")))
Select(select).select_by_visible_text("March")
Also you can use provided by #Murthi //select[#name="filterMonth"] XPath to select drop-down

Selecting pull down item with python selenium

I've been trying to select an item from a pull down list. I've been searching and trying everything. I've tried to search and select by id, xpath, and name. I am at a complete loss. I keep seeing select_by_value but I get the error 'WebElement' object has no attribute 'select_by_value'
The code from the website that I'm trying to select from is as follows.
<input type="hidden" name="wlw-select_key:{actionForm.dobMonth}OldValue" value="true">
<select name="wlw-select_key:{actionForm.dobMonth}" id="dobMonth" class="dobMonth"> <option value="">Select month</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option></select>
I've tried both working with the numerical value and the text value, but neither have worked. I've also tried selecting with the id and then sending keyboard commands. The best that I can get it to do is to open the menu, but it does not change the value.
driver.find_element_by_id('dobMonthSelectBoxItContainer').send_keys("May")
doesn't give errors, but when I find by xpath or name I do get errors. I've been using firepath to get the xpath, which would be
.//*[#id='genderSelectBoxItText']
and
.//*[#id='5']/a
(I've gotten to the 5th page on several google searches :/ Most I see using the select command, but I keep getting that error.)
It's best to use the Select() class when handling a <select> element.
from selenium.webdriver.support.select import Select
select = Select(driver.find_element_by_id("dobMonth"))
select.select_by_visible_text("May")
This is how I handle dropdowns with Selenium
def select_dropdown(driver, dropdown_id, option_value):
dd = driver.find_element_by_id(dropdown_id)
xpath = ".//option[#value='{}']".format(option_value)
dd.find_element_by_xpath(xpath).click()
In your case, if you were trying to select May, as in your example code, it would be select_dropdown(driver, 'dobMonth','05').
I did find a solution, but it is bulky and seems to take more time than necessary. The solution I have created is the following code.
driver.find_element_by_id('dobMonthSelectBoxItText').click()
time.sleep(1) #requires "import time"
driver.find_element_by_id('dobMonthSelectBoxItText').click()
driver.find_element_by_id('5').click()
This seems to open the box twice, but if I remove any line it does not work. I feel that this is bad coding technique, but this is a working solution. I would still appreciate a more elegant solution than this, if anyone finds one.

Insert a dropdownlist inside an article in joomla

Thanks and regards.Hello, I'm trying to put a dropdownlist inside an article but I don't know how, could you help me?, any advice. I use joomla 2.5
All you have to do is insert in your article the HTML code of a drop down list.
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
Go to your article and in the editor you will find a button which is a white page with these symbols: <> (Source Code Editor).
Once you click on this you will see your article in HTML format and you can insert here the code given above and edit it your own way.
Hope this helps.

Play framework select field empty value

How do I add a "none" option to the play framework select field?
So far, I have this:
<select size="1" name="object.id">
<option value="">&{'crud.none'}</option>
#{list items:someItems, as:'item'}
<option value="${item.id}">${item.name}</option>
#{/list}
</select>
but when i select the "none" value, play constructs a new object, and tries to save the parent object with a reference to the newly created object, resulting in a hibernate org.hibernate.TransientObjectException
Any ideas?
Set none option's value to 0 and in your controller add relation only in case if (item.id > 0)
<option value="0">&{'crud.none'}</option>
What's more if this value is required you can use simple check with JavaScript to ensure, that user selected some option