Getting value of multiple <select> that has chosen jquery plugin - jquery-chosen

I have a <select mutiple> which has the chosen function attached to it, turning it into something like a tag selector.
I am then sending its multiple values via an ajax call.
I am currently using this:
var x_CoPayers = $("#x_CoPayersChargeEdit").val();
but when I view the parameters that are sent by ajax, they look like this:
x_CoPayers[] = 9813
x_CoPayers[] = 9786
Of course that doesn't work for me, because the parameter i am looking for on the other side is called x_CoPayers.
I would like them each to be called x_CoPayers, or alternatively, like this: x_CoPayers= 9813,9786.
I have also tried this, without result:
var x_CoPayers = $("#x_CoPayersChargeEdit").chosen().val();
Thank you.

Ok, found the answer ;)
add join(',') at the end, so:
$("#x_CoPayersChargeEdit").val().join(',');

Related

How to compare a template var in the html page in ionic 4

I am a ionic beginner, and I really do not know how to compare a var in *ngIf.
I have a user class, and one of its atribute is averageRating, that is a Number. In my rating.page.html I can show it like this:
{{user.averageRating}} but I want to show it in a more natural way, with stars.
I know I can not compare like this: *ngIf="{{user.averageRating}}>=1"
So I have try to declare a public ratingActual: Number in my class RatingPage in my rating.page.ts and asign value in the constructor:
this.ratingActual = this.user.averageRate;
And I do in my html: *ngIf="ratingActual>=1"
But is not working. However if I change this.user.averageRate by a number it works.
I would like to understand wy is not working and find an solution, an easy one if it is posible.
Thanks in advance!

Angular-material. Autocomplete directive

I have some problem with autocomplete. And my question is: Can I send my own personally typed text instead object from autocomplete list?
When I send object from list to "person.eamil" it's ok, but
when I send normal text to "person.email" I get null instead my text.
Here is my HTML code:
<md-autocomplete
ng-model="person.email"
ng-disabled="false"
md-no-cache="true"
md-selected-item="person.email"
md-search-text-change="setPersonValidEmail(person, !innerForm.email.$error.email);"
md-search-text="searchText"
md-items="item in people"
md-item-text="item.email"
md-min-length="0"
placeholder="some#one.com"
ng-click="addOurPersonIfNecessary($index);"
name = "email">
<md-item-template>
<span md-highlight-text="searchText" md-highlight-flags="^i">{{item.name}}</span>
</md-item-template>
</md-autocomplete>
Md-selected-item here is expecting an object that is populated in people. Only then it can populate the auto complete. You can pass the text to md-search-text
I found solution. Try to use another autocomplete plugin like this:
https://github.com/ghiden/angucomplete-alt

How do I use Perl's Remote::Selenium::WebElement to verify the URL a hyperlink will take me to?

Seems like it should be straightforward but I can't seem to get to the bottom of it.
Here's the HTML I'm working with:
<li id="a" class="FILElevel3" onclick="changeMenu("b")">
<a onclick="stopBubble(event);" href="javascript:LinkPopup('/sub/URL.html')">Visible Text</a>
I'm able to find the element using XPaths:
my $returned_asset = $sel->find_element("//*[\#class='LINKlevel3']");
And I can verify this works because I'm able to extract the visible text from it:
my $returned_name = Selenium::Remote::WebElement::get_text($returned_asset);
I just can't seem to find the sequence to pull the HREF attribute from the element to put the link's URL into a verifiable string. Should I be able to do this using WebElement's get_attribute() method? I've tried variations on this:
my $returned_URL = $returned_asset-> Selenium::Remote::WebElement::get_attribute("a/href");
...where I've plugged in everything I could think of for that "a/href" string. What should go in there?
In the end I'd like to be able to put "javascript:LinkPopup('/sub/URL.html')" into a string and verify that my URL is in there.
have you tried
my $returned_asset = $sel->find_element("//*[\#class='LINKlevel3']/a");
my $returned_URL = $returned_asset->Selenium::Remote::WebElement::get_attribute("href");

question about CodeIgniter urls

I am using an application (a blog) written using the CodeIgniter framework and would like to search my blog from my browsers location bar by adding a string to the end of my blogs url like this:
http://mysite.com/blog/index.php/search...
As you can see in the example above I am not really sure how to format the rest of the url after the search part so I am hoping someone here might be able to point me in the right direction.
This is what the form looks like for the search box if that helps at all.
form class="searchform" action="http://mysite.com/blog/index.php/search" method="post">
<input id="searchtext" class="search_input" type="text" value="" name="searchtext">
<input type="submit" value="Search" name="Search">
</form>
Thx,
Mark
Since your form is posting to http://mysite.com/blog/index.php/search, I'm assuming this 'search' controller's default function is the one your are attempting to submit your data to. I think that the easiest way to do this would be to just grab the post data inside of the controller method you're posting to. Example:
function search()
{
$search_params = $this->input->post('search_text');
}
Then you would have whatever the user input stored as $search_params, and you can take actions from there. Am I misunderstanding what you're asking?
It seems like you're kind of discussing two different approaches. If you wanted to make a request to
mysite.com/blog/index.php/search&q=what_I_am_looking_for
This is going to call the search controllers default method (which is index by default). If you wanted to use the URL to pass parameters like that you would go to your function in the search controller and do:
print_r($this->input->get('q'));
This will print out "what_am_I_looking_for".
An easier approach in my opinion would be to:
1. Create a view called "search_view" with the HTML content you pasted above, and have the form "action" http://www.mysite.com/blog/index.php/test/search
Create a controller called "Test" that looks like the following:
class Test extends CI_Controller {
function search()
{
$search = $this->input->post('searchtext');
print_r($search);
}
public function display_search()
{
$this->load->view('search_view');
}
}
Visit http://www.mysite.com/blog/index.php/test/display_search in your browser. This should present you with the form you placed in search_view.php. Once the form is submitted, you should be sent to the search function and print out the variable $search, which will have whatever text you submitted on that form.
If this isn't what you were looking for then I am afraid I do not understand your question.

ASP.NET MVC 2: Update Partial?

Is it possible to call a controller action that will update (refresh) a partial within the View with the updated model? If so, can someone point me to an example?
I'm making an ajax call. The call sends some json to the controller. The controller extracts the json and formats it into XML that then get's passed on to a SPROC. The results of the SPROC update the model. This is where I need to update the view... with the latest model results.
Yes, you simply need to have the action return the PartialView with its updated model. The calling code might look like this:
<div id="MyDiv"></div>
<%=Ajax.ActionLink("Update", "GetUpdatedPartialView",
new AjaxOptions{UpdateTargetId = "MyDiv"}) %>
When you click on the link, the HTML returned by your action will get placed into the div with ID "MyDiv".
Edit
I don't have my code with me, but if I remember right it's something like this:
var url = '<%=Url.Action("GetUpdatedPartialView")%>';
$.post(url, function(data) {$('#MyDiv').html(data);});
In the controller, you can just do something like:
if (Request.IsAjaxRequest()) {
return View(name_of_partial, updated_model);
}
On the front end, it's just a jQuery load, something like:
$("#target-div").load(url_of_action, data_to_send);