How to get value of selected items from listbox and storing into a variable
up vote
0
down vote
favorite
I use a list box and its item comes from the database i looped it over using while loop. All i want is when I select an item from the dropdown listbox, i can also get other selected item value from the database. Like in the picture, if i select an item in the drop down i need to get its quantity from the database. Thanks
php sql
add a comment |
up vote
0
down vote
favorite
I use a list box and its item comes from the database i looped it over using while loop. All i want is when I select an item from the dropdown listbox, i can also get other selected item value from the database. Like in the picture, if i select an item in the drop down i need to get its quantity from the database. Thanks
php sql
2
What have you tried so far? Are you using any Framework?
– Nebi
Nov 22 at 7:57
No im not im just using native php code. I already have the database value into my drop down. What i dont know is that how can i get the quantity of the selected items. (The quantity is also on the database)
– Charlie Matanguihan
Nov 22 at 8:00
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 at 8:02
Native PHP? You mean Core PHP? Ok then you can do. there are 3 methods.1.using AJAX
and2.using pre-loaded Javascript Array
and3. Add a custom Data-Property
. Choose a method (It depends on how large is your data)
– Banujan Balendrakumar
Nov 22 at 8:04
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I use a list box and its item comes from the database i looped it over using while loop. All i want is when I select an item from the dropdown listbox, i can also get other selected item value from the database. Like in the picture, if i select an item in the drop down i need to get its quantity from the database. Thanks
php sql
I use a list box and its item comes from the database i looped it over using while loop. All i want is when I select an item from the dropdown listbox, i can also get other selected item value from the database. Like in the picture, if i select an item in the drop down i need to get its quantity from the database. Thanks
php sql
php sql
edited Nov 22 at 10:58
Sanal Sunny
6548
6548
asked Nov 22 at 7:54
Charlie Matanguihan
467
467
2
What have you tried so far? Are you using any Framework?
– Nebi
Nov 22 at 7:57
No im not im just using native php code. I already have the database value into my drop down. What i dont know is that how can i get the quantity of the selected items. (The quantity is also on the database)
– Charlie Matanguihan
Nov 22 at 8:00
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 at 8:02
Native PHP? You mean Core PHP? Ok then you can do. there are 3 methods.1.using AJAX
and2.using pre-loaded Javascript Array
and3. Add a custom Data-Property
. Choose a method (It depends on how large is your data)
– Banujan Balendrakumar
Nov 22 at 8:04
add a comment |
2
What have you tried so far? Are you using any Framework?
– Nebi
Nov 22 at 7:57
No im not im just using native php code. I already have the database value into my drop down. What i dont know is that how can i get the quantity of the selected items. (The quantity is also on the database)
– Charlie Matanguihan
Nov 22 at 8:00
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 at 8:02
Native PHP? You mean Core PHP? Ok then you can do. there are 3 methods.1.using AJAX
and2.using pre-loaded Javascript Array
and3. Add a custom Data-Property
. Choose a method (It depends on how large is your data)
– Banujan Balendrakumar
Nov 22 at 8:04
2
2
What have you tried so far? Are you using any Framework?
– Nebi
Nov 22 at 7:57
What have you tried so far? Are you using any Framework?
– Nebi
Nov 22 at 7:57
No im not im just using native php code. I already have the database value into my drop down. What i dont know is that how can i get the quantity of the selected items. (The quantity is also on the database)
– Charlie Matanguihan
Nov 22 at 8:00
No im not im just using native php code. I already have the database value into my drop down. What i dont know is that how can i get the quantity of the selected items. (The quantity is also on the database)
– Charlie Matanguihan
Nov 22 at 8:00
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 at 8:02
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 at 8:02
Native PHP? You mean Core PHP? Ok then you can do. there are 3 methods.
1.using AJAX
and 2.using pre-loaded Javascript Array
and 3. Add a custom Data-Property
. Choose a method (It depends on how large is your data)– Banujan Balendrakumar
Nov 22 at 8:04
Native PHP? You mean Core PHP? Ok then you can do. there are 3 methods.
1.using AJAX
and 2.using pre-loaded Javascript Array
and 3. Add a custom Data-Property
. Choose a method (It depends on how large is your data)– Banujan Balendrakumar
Nov 22 at 8:04
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
If you use Jquery framework,you can get it like this
1:var options=$(“your css selector”); //choose the item
2:options.val(); //selected value
3:options.text(); //selected text
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 at 11:22
add a comment |
up vote
0
down vote
You can try like -
- Try getting selected item's div class. Suppose could be "selected"
Get div value by below -
var selectedListval = $("#ddlist").find('.selected').val();
Do null check for selectedListval and execute ajax call to function - which will serve purpose of fetching quality of selected dropdown item Refer http://api.jquery.com/jquery.ajax/
for ajax syntax.after null check ,bind Quantity value to the Quantity textbox.
Hope this helps you.
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 at 11:06
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If you use Jquery framework,you can get it like this
1:var options=$(“your css selector”); //choose the item
2:options.val(); //selected value
3:options.text(); //selected text
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 at 11:22
add a comment |
up vote
0
down vote
If you use Jquery framework,you can get it like this
1:var options=$(“your css selector”); //choose the item
2:options.val(); //selected value
3:options.text(); //selected text
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 at 11:22
add a comment |
up vote
0
down vote
up vote
0
down vote
If you use Jquery framework,you can get it like this
1:var options=$(“your css selector”); //choose the item
2:options.val(); //selected value
3:options.text(); //selected text
If you use Jquery framework,you can get it like this
1:var options=$(“your css selector”); //choose the item
2:options.val(); //selected value
3:options.text(); //selected text
answered Nov 22 at 8:05
Mr.xu
11
11
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 at 11:22
add a comment |
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 at 11:22
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 at 8:07
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 at 11:22
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 at 11:22
add a comment |
up vote
0
down vote
You can try like -
- Try getting selected item's div class. Suppose could be "selected"
Get div value by below -
var selectedListval = $("#ddlist").find('.selected').val();
Do null check for selectedListval and execute ajax call to function - which will serve purpose of fetching quality of selected dropdown item Refer http://api.jquery.com/jquery.ajax/
for ajax syntax.after null check ,bind Quantity value to the Quantity textbox.
Hope this helps you.
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 at 11:06
add a comment |
up vote
0
down vote
You can try like -
- Try getting selected item's div class. Suppose could be "selected"
Get div value by below -
var selectedListval = $("#ddlist").find('.selected').val();
Do null check for selectedListval and execute ajax call to function - which will serve purpose of fetching quality of selected dropdown item Refer http://api.jquery.com/jquery.ajax/
for ajax syntax.after null check ,bind Quantity value to the Quantity textbox.
Hope this helps you.
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 at 11:06
add a comment |
up vote
0
down vote
up vote
0
down vote
You can try like -
- Try getting selected item's div class. Suppose could be "selected"
Get div value by below -
var selectedListval = $("#ddlist").find('.selected').val();
Do null check for selectedListval and execute ajax call to function - which will serve purpose of fetching quality of selected dropdown item Refer http://api.jquery.com/jquery.ajax/
for ajax syntax.after null check ,bind Quantity value to the Quantity textbox.
Hope this helps you.
You can try like -
- Try getting selected item's div class. Suppose could be "selected"
Get div value by below -
var selectedListval = $("#ddlist").find('.selected').val();
Do null check for selectedListval and execute ajax call to function - which will serve purpose of fetching quality of selected dropdown item Refer http://api.jquery.com/jquery.ajax/
for ajax syntax.after null check ,bind Quantity value to the Quantity textbox.
Hope this helps you.
answered Nov 22 at 9:02
Bharati Mathapati
543
543
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 at 11:06
add a comment |
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 at 11:06
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 at 11:06
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 at 11:06
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426192%2fhow-to-get-value-of-selected-items-from-listbox-and-storing-into-a-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
What have you tried so far? Are you using any Framework?
– Nebi
Nov 22 at 7:57
No im not im just using native php code. I already have the database value into my drop down. What i dont know is that how can i get the quantity of the selected items. (The quantity is also on the database)
– Charlie Matanguihan
Nov 22 at 8:00
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 at 8:02
Native PHP? You mean Core PHP? Ok then you can do. there are 3 methods.
1.using AJAX
and2.using pre-loaded Javascript Array
and3. Add a custom Data-Property
. Choose a method (It depends on how large is your data)– Banujan Balendrakumar
Nov 22 at 8:04