How to get value of selected items from listbox and storing into a variable
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 |
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 '18 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 '18 at 8:00
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 '18 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 '18 at 8:04
add a comment |
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 '18 at 10:58
Sanal Sunny
6628
6628
asked Nov 22 '18 at 7:54
Charlie MatanguihanCharlie Matanguihan
638
638
2
What have you tried so far? Are you using any Framework?
– Nebi
Nov 22 '18 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 '18 at 8:00
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 '18 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 '18 at 8:04
add a comment |
2
What have you tried so far? Are you using any Framework?
– Nebi
Nov 22 '18 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 '18 at 8:00
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 '18 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 '18 at 8:04
2
2
What have you tried so far? Are you using any Framework?
– Nebi
Nov 22 '18 at 7:57
What have you tried so far? Are you using any Framework?
– Nebi
Nov 22 '18 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 '18 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 '18 at 8:00
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 '18 at 8:02
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 '18 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 '18 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 '18 at 8:04
add a comment |
2 Answers
2
active
oldest
votes
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 '18 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 '18 at 11:22
add a comment |
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 '18 at 11:06
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 '18 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 '18 at 11:22
add a comment |
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 '18 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 '18 at 11:22
add a comment |
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 '18 at 8:05
Mr.xuMr.xu
11
11
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 '18 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 '18 at 11:22
add a comment |
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 '18 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 '18 at 11:22
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 '18 at 8:07
Can you explain your code please?
– Banujan Balendrakumar
Nov 22 '18 at 8:07
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 '18 at 11:22
Is it inside form? if so you can grab the value using $_post['fieldname'] or $_GET['fieldname']
– Birhan Nega
Nov 22 '18 at 11:22
add a comment |
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 '18 at 11:06
add a comment |
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 '18 at 11:06
add a comment |
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 '18 at 9:02
Bharati MathapatiBharati Mathapati
543
543
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 '18 at 11:06
add a comment |
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 '18 at 11:06
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 '18 at 11:06
Thanks! @Bharati
– Charlie Matanguihan
Nov 22 '18 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.
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 '18 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 '18 at 8:00
@Nebi can you recommend some documentation on how to solve my problem?
– Charlie Matanguihan
Nov 22 '18 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 '18 at 8:04