0

I have a JQuery function in which I am trying get the value of select field from my HTML.

$('.selectCurrency').change(function(){
        //alert(this.value);
        alert("{{$users["+this.value+"]->currency}}");
});

Its throwing error in this.value.

Any suggestions how I can get the value?

1
  • This is not possible. PHP runs on the server, JS on the client. The two cannot directly interact as you are attempting. To pass a JS value to PHP you would be best to make an AJAX request. Commented Feb 23, 2016 at 11:18

1 Answer 1

-1

Just use the .val() function in jQuery. http://api.jquery.com/val/

Sign up to request clarification or add additional context in comments.

3 Comments

That's not a very useful reply. I'm pretty sure it will work once you do it correctly.
I used it like this alert("{{$users["+$(this).val()+"]->currency}}") any other method you will suggest?
Yes - not using it like that. Please read the documentation that I linked - it provides you with all the information you need. $('.selectCurrency:selected').val();

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.