Can't rendering data from function mount() laravel livewire - laravel-livewire

I have some problem in laravel livewire, when I try to bring up data that i define inside mount() function in the class component which the two relate to each other, but the data doesn't show up on view component
public function mount()
{
$this->allOwners = Owner::all();
$this->allVehicles = Vehicle::where('owner_id', $this->owner_id)->get();
$this->allOrders = [
['owner_id' => '', 'vehicle_id' => '', 'bbn_kb' => '']
];
$this->resetPage();
}
#foreach($allOrders as $index => $allOrder)
<x-jet-label for="allOrders[{{ $index }}][owner_id]" value="{{ __('Nama Pemilik') }}"/>
<select wire:model="allOrders.{{ $index }}.owner_id" name="allOrders[{{ $index}}] owner_id]" id="allOrders[{{ $index }}][owner_id]">
#foreach ($allOwners as $owner)
<option value="{{ $owner->id }}">{{ $owner->nama }}</option>
#endforeach
</select>
<x-jet-label for="allOrders[{{ $index }}][vehicle_id]" value="{{ __('Pilih No. Faktur') }}" />
<select wire:model="allOrders.{{ $index }}.vehicle_id" name="allOrders[{{$index}}][vehicle_id]" id="allOrders[{{ $index }}][vehicle_id]">
#foreach ($allVehicles as $vehicle)
<option value="{{ $vehicle->id }}">{{ $vehicle->no_faktur }}</option>
#endforeach
</select>
#endforeach

Related

How to get the value from the drop down box django? without submit button

How to get the value from the dropDown Box in Django Without Submit Button
<div class="single-shorter">
<form action="." method="GET">
<label>Sort By :</label>
<select name="val" id="val">
<option selected="selected" value="name">Name</option>
<option value="price">Price</option>
</select>
</form>
</div>
You can simple obtain it using Ajax but as mentioned in comments in dont want to use that u can use value attribute in option value and using event listner and window.loction.href we can obtain this... This is one example
<select id="foo">
<option value="">Your Dropdown</option>
<option value="http://www.google.com">x</option>
<option value="http://www.facebook.com">y</option>
</select>
<script>
document.getElementById("foo").onchange = function() {
if (this.selectedIndex!==0) {
window.location.href = this.value;
}
};
</script>
as u are using django use this and also dont want to change the value attribute
<select id="my_selection">
<option value="x" href="/link/to/somewhere">value 1</option>
<option value="y" href="/link/to/somewhere/else">value 2</option>
</select>
<script>
document.getElementById('my_selection').onchange = function() {
window.location.href = this.children[this.selectedIndex].getAttribute('href');
}
</script>

How can pass variable to a template and receive variable in beego

My template file:
{{range $index, $option := .alternatives}}
<div id="splashAlternative{{$index}}" class="col-sm-2">
<select id="flashSrc_{{$index}}">
{{template "alternative_src.html" $option}}
</select>
</div>
{{end}}
I want pass $option to template, and alternative_src.html code :
{{if compare .option ""}}
<option value="" selected="selected">
</option>
{{else}}
<option value=""></option>
{{end}}
{{if compare .option "xxx"}}
<option value="xxx" selected="selected">xxx</option>
{{else}}
<option value="xxx">xxx</option>
{{end}}
but I get problem below:
executing "alternative_src.html" at <.option>: can't evaluate field option in type string
When you use the {{template}} action and you pass something, that becomes the dot . in the called template. Quoting from the package doc of text/template:
{{template "name" pipeline}}
The template with the specified name is executed with dot set
to the value of the pipeline.
So inside alternative_src.html refer to the option only as a dot . (the dot . will mean the value of the pipeline you passed to the template, which is $option in the caller template):
{{if compare . ""}}
<option value="" selected="selected">
</option>
{{else}}
<option value=""></option>
{{end}}
{{if compare . "xxx"}}
<option value="xxx" selected="selected">xxx</option>
{{else}}
<option value="xxx">xxx</option>
{{end}}

Laravel Select Menu / Dropdown

I am using the following code:
<select onchange="javascript:location.href = this.value;">
<option value="" selected>-- Show Genre --</option>
#foreach ($genres as $genre)
<option value="{{ URL::route('tracks.order', array('order' => 'name', 'by' => 'asc', 'genre' => $genre->name )) }}">{{ $genre->name }}</option>
#endforeach
</select>
The $genres is populated using the following code in my controller:
$genres = Genres::lists('name', 'id');
I was wondering if I could use a code like below instead of the foreach? I think I should be able to, but I have no clue on how to change the code to work with my code above.
{{ Form::select('genre', array('default' => '-- Select Genre --') + $genres, '') }}
You may try something like this:
$genres = ['default' => '-- Select Genre --'] + Genres::lists('name', 'id');
In the view:
{{ Form::select('genre', $genres, Form::old('genre')) }}

Trying to fill a form with Scrapy FormRequest, unexpected results

I'm trying to fill the form that is at www.wetseal.com/Stores that allows selecting the state to show stores from.
<form action="http://www.wetseal.com/Stores?dwcont=C73689620" method="post" id="dwfrm_storelocator_state">
<fieldset>
<div class="form-row required ">
<label for="dwfrm_storelocator_address_states_stateUSCA">
<span>State</span>
<span class="required-indicator">*</span>
</label>
<select id="dwfrm_storelocator_address_states_stateUSCA" class="input-select required" name="dwfrm_storelocator_address_states_stateUSCA">
<option value="">Select...</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="PR">Puerto Rico</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
</select>
</div>
<button type="submit" name="dwfrm_storelocator_findbystate" value="Search">
Search
</button>
</fieldset>
</form>
Looking with Chrome I can see the request being made and the form params:
That said, I have a very simple spider that, looking at the docs, sends a FormRequest to that URL to fill the form (In this case I'm testing for Arizona shops - AZ):
class WetSealStoreSpider(Spider):
name = "wetseal_store_spider"
allowed_domains = ["wetseal.com"]
start_urls = [
"http://www.wetseal.com/Stores"
]
def parse(self, response):
yield FormRequest.from_response(response,
formname='dwfrm_storelocator_state',
formdata={'dwfrm_storelocator_address_states_stateUSCA': 'AZ',
'dwfrm_storelocator_findbystate': 'Search'},
callback=self.parse1)
def parse1(self, response):
print response.status
print response.body
When it gets to make the FormRequest, looking at the response, everything seems OK:
But in the callback method, I see this in the response:
It looked like a GET request was made at the end, and the url is all wrong:
'http://www.wetseal.com/Search?q=&dwfrm_storelocator_findbystate=Search&dwfrm_storelocator_address_states_stateUSCA=AZ'
Any idea what I'm doing wrong?
Thanks!
You're using formname but the form doesn't have a name.
Try using formxpath='id("dwfrm_storelocator_state")' instead.
try this
states = response.xpath(
".//select[#id='dwfrm_storelocator_address_states_stateUSCA']//option[#value!='']/#value").extract()
url = self.get_text_from_node(response.xpath("//form[#id='dwfrm_storelocator_state']/#action"))
for state in states:
form_data = {'dwfrm_storelocator_address_states_stateUSCA': state,
"dwfrm_storelocator_findbystate": "Search"}
yield FormRequest(url,
formdata=form_data,
callback=self.your_Callback)

Transfer Value from drop down to a

I need some help ...
I need the location drop down box to determine the appropriate inbox the form should be sent to.
ex if I choose Houston from the drop down box it will send it to the PayrollUSA email.
Im currently using a radio button to make the selection but i would like to automate with the drop down.
Im pretty new to this but im sure theres a if statement that can tie them together...
im using .asp for this.
<input type="radio" name="payroll" value="PayrollUSA#mail.com" checked="checked">US Payroll
<input type="radio" name="payroll" value="PayrollCAN#mail.com">CAN Payroll
<input type="radio" name="payroll" value="PayrollUK#mail.com">UK Payroll
<input type="radio" name="payroll" value="PayrollHK#mail.com">HK Payroll
Drop down selection
<SELECT SIZE="1" NAME="Business_Unit" style="width: 205px;" class="answers">
<option selected >Select</option>
<OPTION>Calgary</OPTION>
<OPTION>Chicago</OPTION>
<OPTION>Hong Kong</OPTION>
<OPTION>Houston</OPTION>
<OPTION>London</OPTION>
<OPTION>Los Angeles</OPTION>
<OPTION>Montreal</OPTION>
<OPTION>New York</OPTION>
<OPTION>New York Corporate</OPTION>
<OPTION>Philadelphia</OPTION>
<OPTION>San Francisco</OPTION>
<OPTION>Toronto</OPTION>
<OPTION>Toronto Corporate</OPTION>
<OPTION>Vancouver</OPTION>
</SELECT>
If you need the option value to be held then try this:
<SELECT SIZE="1" NAME="Business_Unit" style="width: 205px;" class="answers">
<option value="">Select an Option</option>
<option <% if Business_Unit= "PayrollCAN#mail.com" then %> selected <% End if %> value="PayrollCAN#mail.com">Calgary</option>
<option <% if Business_Unit= "PayrollUSA#mail.com" then %> selected <% End if %> value="PayrollUSA#mail.com">Chicago</option>
</select>
etc. for each option and same value may be used for different option displays
I imaging this should just be html based. So your option menu should look like:
<SELECT SIZE="1" NAME="Business_Unit" style="width: 205px;" class="answers">
<option value="-1">Select an Option</option>
<OPTION value="PayrollCAN#mail.com">Calgary</OPTION>
<OPTION value="PayrollUSA#mail.com">Chicago</OPTION>
<OPTION value="PayrollHK#mail.com">Hong Kong</OPTION>
<OPTION value="PayrollUSA#mail.com">Houston</OPTION>
<OPTION value="PayrollUK#mail.com">London</OPTION>
<OPTION value="PayrollUSA#mail.com">Los Angeles</OPTION>
<OPTION value="PayrollCAN#mail.com">Montreal</OPTION>
<OPTION value="PayrollUSA#mail.com">New York</OPTION>
<OPTION value="PayrollUSA#mail.com">New York Corporate</OPTION>
<OPTION value="PayrollUSA#mail.com">Philadelphia</OPTION>
<OPTION value="PayrollUSA#mail.com">San Francisco</OPTION>
<OPTION value="PayrollCAN#mail.com">Toronto</OPTION>
<OPTION value="PayrollCAN#mail.com">Toronto Corporate</OPTION>
<OPTION value="PayrollCAN#mail.com">Vancouver</OPTION>
</SELECT>
You can use the same value multiple times if needed