How do I pass the id value to the function?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















How do I pass the id value to the function?
What I am doing is, When the user changes the dropdown then it will get the value of dropdown and also get the input value which is hidden inside foreach.



I tried from my side I am getting on change the value from the dropdown but how do I get the input value in the jquery? now I am getting the last value of the input field.



 $x=1;
foreach ($duration as $row) {?>
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>

<?php $x++;}


jquery



$('[id^="Duration"]').change(function () {
var a=$('input[id^="activeID"]').attr('id');// how to I display the input id here
alert(a);
var value = $('input[id^="activityID"]').val();// i tried this one as well
alert(value);
var end = this.value;
alert(end);//getting drodpown id value
});









share|improve this question




















  • 1





    Try to access the element using $(this)

    – Ramesh
    Jan 3 at 5:16











  • Where should I use this?

    – user9437856
    Jan 3 at 5:16











  • select is inside foreach ???

    – sradha
    Jan 3 at 5:22











  • I recommend put the select and input in the same div and then when you change the dropdown, get the siblings()

    – user1334621
    Jan 3 at 5:26











  • @sradha, Yes, you can check in the question. select and input field both are inside foreach.

    – user9437856
    Jan 3 at 5:26


















0















How do I pass the id value to the function?
What I am doing is, When the user changes the dropdown then it will get the value of dropdown and also get the input value which is hidden inside foreach.



I tried from my side I am getting on change the value from the dropdown but how do I get the input value in the jquery? now I am getting the last value of the input field.



 $x=1;
foreach ($duration as $row) {?>
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>

<?php $x++;}


jquery



$('[id^="Duration"]').change(function () {
var a=$('input[id^="activeID"]').attr('id');// how to I display the input id here
alert(a);
var value = $('input[id^="activityID"]').val();// i tried this one as well
alert(value);
var end = this.value;
alert(end);//getting drodpown id value
});









share|improve this question




















  • 1





    Try to access the element using $(this)

    – Ramesh
    Jan 3 at 5:16











  • Where should I use this?

    – user9437856
    Jan 3 at 5:16











  • select is inside foreach ???

    – sradha
    Jan 3 at 5:22











  • I recommend put the select and input in the same div and then when you change the dropdown, get the siblings()

    – user1334621
    Jan 3 at 5:26











  • @sradha, Yes, you can check in the question. select and input field both are inside foreach.

    – user9437856
    Jan 3 at 5:26














0












0








0








How do I pass the id value to the function?
What I am doing is, When the user changes the dropdown then it will get the value of dropdown and also get the input value which is hidden inside foreach.



I tried from my side I am getting on change the value from the dropdown but how do I get the input value in the jquery? now I am getting the last value of the input field.



 $x=1;
foreach ($duration as $row) {?>
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>

<?php $x++;}


jquery



$('[id^="Duration"]').change(function () {
var a=$('input[id^="activeID"]').attr('id');// how to I display the input id here
alert(a);
var value = $('input[id^="activityID"]').val();// i tried this one as well
alert(value);
var end = this.value;
alert(end);//getting drodpown id value
});









share|improve this question
















How do I pass the id value to the function?
What I am doing is, When the user changes the dropdown then it will get the value of dropdown and also get the input value which is hidden inside foreach.



I tried from my side I am getting on change the value from the dropdown but how do I get the input value in the jquery? now I am getting the last value of the input field.



 $x=1;
foreach ($duration as $row) {?>
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>

<?php $x++;}


jquery



$('[id^="Duration"]').change(function () {
var a=$('input[id^="activeID"]').attr('id');// how to I display the input id here
alert(a);
var value = $('input[id^="activityID"]').val();// i tried this one as well
alert(value);
var end = this.value;
alert(end);//getting drodpown id value
});






php jquery html5






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 5:28







user9437856

















asked Jan 3 at 5:13









user9437856user9437856

471314




471314








  • 1





    Try to access the element using $(this)

    – Ramesh
    Jan 3 at 5:16











  • Where should I use this?

    – user9437856
    Jan 3 at 5:16











  • select is inside foreach ???

    – sradha
    Jan 3 at 5:22











  • I recommend put the select and input in the same div and then when you change the dropdown, get the siblings()

    – user1334621
    Jan 3 at 5:26











  • @sradha, Yes, you can check in the question. select and input field both are inside foreach.

    – user9437856
    Jan 3 at 5:26














  • 1





    Try to access the element using $(this)

    – Ramesh
    Jan 3 at 5:16











  • Where should I use this?

    – user9437856
    Jan 3 at 5:16











  • select is inside foreach ???

    – sradha
    Jan 3 at 5:22











  • I recommend put the select and input in the same div and then when you change the dropdown, get the siblings()

    – user1334621
    Jan 3 at 5:26











  • @sradha, Yes, you can check in the question. select and input field both are inside foreach.

    – user9437856
    Jan 3 at 5:26








1




1





Try to access the element using $(this)

– Ramesh
Jan 3 at 5:16





Try to access the element using $(this)

– Ramesh
Jan 3 at 5:16













Where should I use this?

– user9437856
Jan 3 at 5:16





Where should I use this?

– user9437856
Jan 3 at 5:16













select is inside foreach ???

– sradha
Jan 3 at 5:22





select is inside foreach ???

– sradha
Jan 3 at 5:22













I recommend put the select and input in the same div and then when you change the dropdown, get the siblings()

– user1334621
Jan 3 at 5:26





I recommend put the select and input in the same div and then when you change the dropdown, get the siblings()

– user1334621
Jan 3 at 5:26













@sradha, Yes, you can check in the question. select and input field both are inside foreach.

– user9437856
Jan 3 at 5:26





@sradha, Yes, you can check in the question. select and input field both are inside foreach.

– user9437856
Jan 3 at 5:26












5 Answers
5






active

oldest

votes


















1














You can put your input and select inside a div. When the dropdowns are changed, get the input sibling



<?php
$x=1;
foreach ($duration as $row) {
?>
<div>
//Your input and select here
</div>
<?php } ?>


<script>

$('[id^="Duration"]').change(function () {
var input = $($(this).siblings("input")[0]); // get the input element
var id = input.attr("id"); //id of the input
var value = input.val(); //value of the input
alert(value);
});
</script>





share|improve this answer


























  • thanks for the answer, I got a error in console after selecting the dropdown "TypeError: $(...).siblings(...)[0].val is not a functio"

    – user9437856
    Jan 3 at 6:00











  • Oh! you updated the code. wait let me check again

    – user9437856
    Jan 3 at 6:01











  • It's giving me a error "TypeError: input.attr is not a function"

    – user9437856
    Jan 3 at 6:02











  • @user9437856: sorry my bad, the siblings()[0] return a html element, I have to parse it to jquery object. I updated my code, please try again

    – user1334621
    Jan 3 at 6:06








  • 1





    The logic would be the same, you put the <div id="results<?php echo $x;?>"> inside the new div and then get the siblings("div")[0] of the <select> when it changes value

    – user1334621
    Jan 3 at 22:22





















1














One thing I have observed in your code:



$x=1;
foreach ($duration as $row) {
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>
}


You are not at all increasing $x anywhere and hence each and every hidden input tag is getting id = 'activeId1'






share|improve this answer


























  • Oh! Let me check again my code.

    – user9437856
    Jan 3 at 5:27











  • Sure, Thanks :)

    – Ayush Jain
    Jan 3 at 5:28











  • It's my fault I forgot to add in the question. I added in the question.

    – user9437856
    Jan 3 at 5:29











  • in the view source I am getting "activeId1" or ""activeId2" and so on.

    – user9437856
    Jan 3 at 5:55



















0














<?php

$x=1;
foreach ($duration as $row) {
?>
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control DurationClass" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>
<?php } ?>


<script>

$('.DurationClass').change(function () {
var a=$('input[id^="activeID"]').attr('id');
var selectID=$(this).attr('id');
//alert(a);
var value = $(this).val(); // in loop every dropdown select current option value return
alert(value);

});
</script>





share|improve this answer
























  • If I try var selectID=$(this).attr('id'); then it's displaying only the dropdown Id not input value.

    – user9437856
    Jan 3 at 5:36











  • forget this line and user var value = $(this).val(); these return to current drop down select value.

    – Vijendra Yadav
    Jan 4 at 6:16











  • I don't want current drop-down select value. that I am already getting it. catcon, answer solved my issue.

    – user9437856
    Jan 4 at 6:19



















0














You can use onchange event in your HTML part of the code



$x=1;
foreach ($duration as $row) {?>
<input type="hidden" class="activeID" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" onchange="myfunction();" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>

<?php $x++;}


Here is the function



function myfunction () {
alert($(this).parent()); //what are you getting
alert($(this).parent().find(".activeID").value()); //what are you getting?
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
};





share|improve this answer


























  • I just want to know, how it will display the input field value in the alert?

    – user9437856
    Jan 3 at 6:07











  • @user9437856 okay I just showed above the value and id both in alert. you can remove the id part.

    – Sayed Mohd Ali
    Jan 3 at 6:10











  • @user9437856 ok I got it what you are looking for try the above code and tell me what output you are getting.

    – Sayed Mohd Ali
    Jan 3 at 6:29



















-1

















$(".select").change(function(){
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
});

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
<h2>Form control: select</h2>
<p>The form below contains two dropdown menus (select lists):</p>
<form>
<div class="form-group">
<label for="sel1">Select list (select one):</label>
<select class="form-control select" id="Sell">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<label for="sel1-item">Select list sell item (select one):</label>
<select class="form-control select" id="Sell-item">
<option>car</option>
<option>bike</option>
<option>cycle</option>
<option>auto</option>
</select>
</div>
</form>
</div>

</body>
</html>








share|improve this answer
























  • I think you have to check my code again, You edited my code and remove the $x++ also you remove the PHP tags after foreach.

    – user9437856
    Jan 3 at 5:48











  • Also in your answer, you haven't use the input fields. I have input field inside foreach and I need that value.

    – user9437856
    Jan 3 at 5:51











  • I have just given the sample for jquery.

    – Cryptex Technologies
    Jan 3 at 5:52











  • That is not my issue, but thanks for the answer, Jquery which you shared that already in my code and that it working. I need input field value in the jquery and i.e. not in your answer.

    – user9437856
    Jan 3 at 5:57












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016681%2fhow-do-i-pass-the-id-value-to-the-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























5 Answers
5






active

oldest

votes








5 Answers
5






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can put your input and select inside a div. When the dropdowns are changed, get the input sibling



<?php
$x=1;
foreach ($duration as $row) {
?>
<div>
//Your input and select here
</div>
<?php } ?>


<script>

$('[id^="Duration"]').change(function () {
var input = $($(this).siblings("input")[0]); // get the input element
var id = input.attr("id"); //id of the input
var value = input.val(); //value of the input
alert(value);
});
</script>





share|improve this answer


























  • thanks for the answer, I got a error in console after selecting the dropdown "TypeError: $(...).siblings(...)[0].val is not a functio"

    – user9437856
    Jan 3 at 6:00











  • Oh! you updated the code. wait let me check again

    – user9437856
    Jan 3 at 6:01











  • It's giving me a error "TypeError: input.attr is not a function"

    – user9437856
    Jan 3 at 6:02











  • @user9437856: sorry my bad, the siblings()[0] return a html element, I have to parse it to jquery object. I updated my code, please try again

    – user1334621
    Jan 3 at 6:06








  • 1





    The logic would be the same, you put the <div id="results<?php echo $x;?>"> inside the new div and then get the siblings("div")[0] of the <select> when it changes value

    – user1334621
    Jan 3 at 22:22


















1














You can put your input and select inside a div. When the dropdowns are changed, get the input sibling



<?php
$x=1;
foreach ($duration as $row) {
?>
<div>
//Your input and select here
</div>
<?php } ?>


<script>

$('[id^="Duration"]').change(function () {
var input = $($(this).siblings("input")[0]); // get the input element
var id = input.attr("id"); //id of the input
var value = input.val(); //value of the input
alert(value);
});
</script>





share|improve this answer


























  • thanks for the answer, I got a error in console after selecting the dropdown "TypeError: $(...).siblings(...)[0].val is not a functio"

    – user9437856
    Jan 3 at 6:00











  • Oh! you updated the code. wait let me check again

    – user9437856
    Jan 3 at 6:01











  • It's giving me a error "TypeError: input.attr is not a function"

    – user9437856
    Jan 3 at 6:02











  • @user9437856: sorry my bad, the siblings()[0] return a html element, I have to parse it to jquery object. I updated my code, please try again

    – user1334621
    Jan 3 at 6:06








  • 1





    The logic would be the same, you put the <div id="results<?php echo $x;?>"> inside the new div and then get the siblings("div")[0] of the <select> when it changes value

    – user1334621
    Jan 3 at 22:22
















1












1








1







You can put your input and select inside a div. When the dropdowns are changed, get the input sibling



<?php
$x=1;
foreach ($duration as $row) {
?>
<div>
//Your input and select here
</div>
<?php } ?>


<script>

$('[id^="Duration"]').change(function () {
var input = $($(this).siblings("input")[0]); // get the input element
var id = input.attr("id"); //id of the input
var value = input.val(); //value of the input
alert(value);
});
</script>





share|improve this answer















You can put your input and select inside a div. When the dropdowns are changed, get the input sibling



<?php
$x=1;
foreach ($duration as $row) {
?>
<div>
//Your input and select here
</div>
<?php } ?>


<script>

$('[id^="Duration"]').change(function () {
var input = $($(this).siblings("input")[0]); // get the input element
var id = input.attr("id"); //id of the input
var value = input.val(); //value of the input
alert(value);
});
</script>






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 6:05

























answered Jan 3 at 5:57







user1334621




















  • thanks for the answer, I got a error in console after selecting the dropdown "TypeError: $(...).siblings(...)[0].val is not a functio"

    – user9437856
    Jan 3 at 6:00











  • Oh! you updated the code. wait let me check again

    – user9437856
    Jan 3 at 6:01











  • It's giving me a error "TypeError: input.attr is not a function"

    – user9437856
    Jan 3 at 6:02











  • @user9437856: sorry my bad, the siblings()[0] return a html element, I have to parse it to jquery object. I updated my code, please try again

    – user1334621
    Jan 3 at 6:06








  • 1





    The logic would be the same, you put the <div id="results<?php echo $x;?>"> inside the new div and then get the siblings("div")[0] of the <select> when it changes value

    – user1334621
    Jan 3 at 22:22





















  • thanks for the answer, I got a error in console after selecting the dropdown "TypeError: $(...).siblings(...)[0].val is not a functio"

    – user9437856
    Jan 3 at 6:00











  • Oh! you updated the code. wait let me check again

    – user9437856
    Jan 3 at 6:01











  • It's giving me a error "TypeError: input.attr is not a function"

    – user9437856
    Jan 3 at 6:02











  • @user9437856: sorry my bad, the siblings()[0] return a html element, I have to parse it to jquery object. I updated my code, please try again

    – user1334621
    Jan 3 at 6:06








  • 1





    The logic would be the same, you put the <div id="results<?php echo $x;?>"> inside the new div and then get the siblings("div")[0] of the <select> when it changes value

    – user1334621
    Jan 3 at 22:22



















thanks for the answer, I got a error in console after selecting the dropdown "TypeError: $(...).siblings(...)[0].val is not a functio"

– user9437856
Jan 3 at 6:00





thanks for the answer, I got a error in console after selecting the dropdown "TypeError: $(...).siblings(...)[0].val is not a functio"

– user9437856
Jan 3 at 6:00













Oh! you updated the code. wait let me check again

– user9437856
Jan 3 at 6:01





Oh! you updated the code. wait let me check again

– user9437856
Jan 3 at 6:01













It's giving me a error "TypeError: input.attr is not a function"

– user9437856
Jan 3 at 6:02





It's giving me a error "TypeError: input.attr is not a function"

– user9437856
Jan 3 at 6:02













@user9437856: sorry my bad, the siblings()[0] return a html element, I have to parse it to jquery object. I updated my code, please try again

– user1334621
Jan 3 at 6:06







@user9437856: sorry my bad, the siblings()[0] return a html element, I have to parse it to jquery object. I updated my code, please try again

– user1334621
Jan 3 at 6:06






1




1





The logic would be the same, you put the <div id="results<?php echo $x;?>"> inside the new div and then get the siblings("div")[0] of the <select> when it changes value

– user1334621
Jan 3 at 22:22







The logic would be the same, you put the <div id="results<?php echo $x;?>"> inside the new div and then get the siblings("div")[0] of the <select> when it changes value

– user1334621
Jan 3 at 22:22















1














One thing I have observed in your code:



$x=1;
foreach ($duration as $row) {
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>
}


You are not at all increasing $x anywhere and hence each and every hidden input tag is getting id = 'activeId1'






share|improve this answer


























  • Oh! Let me check again my code.

    – user9437856
    Jan 3 at 5:27











  • Sure, Thanks :)

    – Ayush Jain
    Jan 3 at 5:28











  • It's my fault I forgot to add in the question. I added in the question.

    – user9437856
    Jan 3 at 5:29











  • in the view source I am getting "activeId1" or ""activeId2" and so on.

    – user9437856
    Jan 3 at 5:55
















1














One thing I have observed in your code:



$x=1;
foreach ($duration as $row) {
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>
}


You are not at all increasing $x anywhere and hence each and every hidden input tag is getting id = 'activeId1'






share|improve this answer


























  • Oh! Let me check again my code.

    – user9437856
    Jan 3 at 5:27











  • Sure, Thanks :)

    – Ayush Jain
    Jan 3 at 5:28











  • It's my fault I forgot to add in the question. I added in the question.

    – user9437856
    Jan 3 at 5:29











  • in the view source I am getting "activeId1" or ""activeId2" and so on.

    – user9437856
    Jan 3 at 5:55














1












1








1







One thing I have observed in your code:



$x=1;
foreach ($duration as $row) {
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>
}


You are not at all increasing $x anywhere and hence each and every hidden input tag is getting id = 'activeId1'






share|improve this answer















One thing I have observed in your code:



$x=1;
foreach ($duration as $row) {
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>
}


You are not at all increasing $x anywhere and hence each and every hidden input tag is getting id = 'activeId1'







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 5:28









Ramesh

1,272420




1,272420










answered Jan 3 at 5:26









Ayush JainAyush Jain

1437




1437













  • Oh! Let me check again my code.

    – user9437856
    Jan 3 at 5:27











  • Sure, Thanks :)

    – Ayush Jain
    Jan 3 at 5:28











  • It's my fault I forgot to add in the question. I added in the question.

    – user9437856
    Jan 3 at 5:29











  • in the view source I am getting "activeId1" or ""activeId2" and so on.

    – user9437856
    Jan 3 at 5:55



















  • Oh! Let me check again my code.

    – user9437856
    Jan 3 at 5:27











  • Sure, Thanks :)

    – Ayush Jain
    Jan 3 at 5:28











  • It's my fault I forgot to add in the question. I added in the question.

    – user9437856
    Jan 3 at 5:29











  • in the view source I am getting "activeId1" or ""activeId2" and so on.

    – user9437856
    Jan 3 at 5:55

















Oh! Let me check again my code.

– user9437856
Jan 3 at 5:27





Oh! Let me check again my code.

– user9437856
Jan 3 at 5:27













Sure, Thanks :)

– Ayush Jain
Jan 3 at 5:28





Sure, Thanks :)

– Ayush Jain
Jan 3 at 5:28













It's my fault I forgot to add in the question. I added in the question.

– user9437856
Jan 3 at 5:29





It's my fault I forgot to add in the question. I added in the question.

– user9437856
Jan 3 at 5:29













in the view source I am getting "activeId1" or ""activeId2" and so on.

– user9437856
Jan 3 at 5:55





in the view source I am getting "activeId1" or ""activeId2" and so on.

– user9437856
Jan 3 at 5:55











0














<?php

$x=1;
foreach ($duration as $row) {
?>
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control DurationClass" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>
<?php } ?>


<script>

$('.DurationClass').change(function () {
var a=$('input[id^="activeID"]').attr('id');
var selectID=$(this).attr('id');
//alert(a);
var value = $(this).val(); // in loop every dropdown select current option value return
alert(value);

});
</script>





share|improve this answer
























  • If I try var selectID=$(this).attr('id'); then it's displaying only the dropdown Id not input value.

    – user9437856
    Jan 3 at 5:36











  • forget this line and user var value = $(this).val(); these return to current drop down select value.

    – Vijendra Yadav
    Jan 4 at 6:16











  • I don't want current drop-down select value. that I am already getting it. catcon, answer solved my issue.

    – user9437856
    Jan 4 at 6:19
















0














<?php

$x=1;
foreach ($duration as $row) {
?>
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control DurationClass" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>
<?php } ?>


<script>

$('.DurationClass').change(function () {
var a=$('input[id^="activeID"]').attr('id');
var selectID=$(this).attr('id');
//alert(a);
var value = $(this).val(); // in loop every dropdown select current option value return
alert(value);

});
</script>





share|improve this answer
























  • If I try var selectID=$(this).attr('id'); then it's displaying only the dropdown Id not input value.

    – user9437856
    Jan 3 at 5:36











  • forget this line and user var value = $(this).val(); these return to current drop down select value.

    – Vijendra Yadav
    Jan 4 at 6:16











  • I don't want current drop-down select value. that I am already getting it. catcon, answer solved my issue.

    – user9437856
    Jan 4 at 6:19














0












0








0







<?php

$x=1;
foreach ($duration as $row) {
?>
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control DurationClass" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>
<?php } ?>


<script>

$('.DurationClass').change(function () {
var a=$('input[id^="activeID"]').attr('id');
var selectID=$(this).attr('id');
//alert(a);
var value = $(this).val(); // in loop every dropdown select current option value return
alert(value);

});
</script>





share|improve this answer













<?php

$x=1;
foreach ($duration as $row) {
?>
<input type="hidden" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" class="form-control DurationClass" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>
<?php } ?>


<script>

$('.DurationClass').change(function () {
var a=$('input[id^="activeID"]').attr('id');
var selectID=$(this).attr('id');
//alert(a);
var value = $(this).val(); // in loop every dropdown select current option value return
alert(value);

});
</script>






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 5:28









Vijendra YadavVijendra Yadav

11




11













  • If I try var selectID=$(this).attr('id'); then it's displaying only the dropdown Id not input value.

    – user9437856
    Jan 3 at 5:36











  • forget this line and user var value = $(this).val(); these return to current drop down select value.

    – Vijendra Yadav
    Jan 4 at 6:16











  • I don't want current drop-down select value. that I am already getting it. catcon, answer solved my issue.

    – user9437856
    Jan 4 at 6:19



















  • If I try var selectID=$(this).attr('id'); then it's displaying only the dropdown Id not input value.

    – user9437856
    Jan 3 at 5:36











  • forget this line and user var value = $(this).val(); these return to current drop down select value.

    – Vijendra Yadav
    Jan 4 at 6:16











  • I don't want current drop-down select value. that I am already getting it. catcon, answer solved my issue.

    – user9437856
    Jan 4 at 6:19

















If I try var selectID=$(this).attr('id'); then it's displaying only the dropdown Id not input value.

– user9437856
Jan 3 at 5:36





If I try var selectID=$(this).attr('id'); then it's displaying only the dropdown Id not input value.

– user9437856
Jan 3 at 5:36













forget this line and user var value = $(this).val(); these return to current drop down select value.

– Vijendra Yadav
Jan 4 at 6:16





forget this line and user var value = $(this).val(); these return to current drop down select value.

– Vijendra Yadav
Jan 4 at 6:16













I don't want current drop-down select value. that I am already getting it. catcon, answer solved my issue.

– user9437856
Jan 4 at 6:19





I don't want current drop-down select value. that I am already getting it. catcon, answer solved my issue.

– user9437856
Jan 4 at 6:19











0














You can use onchange event in your HTML part of the code



$x=1;
foreach ($duration as $row) {?>
<input type="hidden" class="activeID" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" onchange="myfunction();" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>

<?php $x++;}


Here is the function



function myfunction () {
alert($(this).parent()); //what are you getting
alert($(this).parent().find(".activeID").value()); //what are you getting?
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
};





share|improve this answer


























  • I just want to know, how it will display the input field value in the alert?

    – user9437856
    Jan 3 at 6:07











  • @user9437856 okay I just showed above the value and id both in alert. you can remove the id part.

    – Sayed Mohd Ali
    Jan 3 at 6:10











  • @user9437856 ok I got it what you are looking for try the above code and tell me what output you are getting.

    – Sayed Mohd Ali
    Jan 3 at 6:29
















0














You can use onchange event in your HTML part of the code



$x=1;
foreach ($duration as $row) {?>
<input type="hidden" class="activeID" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" onchange="myfunction();" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>

<?php $x++;}


Here is the function



function myfunction () {
alert($(this).parent()); //what are you getting
alert($(this).parent().find(".activeID").value()); //what are you getting?
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
};





share|improve this answer


























  • I just want to know, how it will display the input field value in the alert?

    – user9437856
    Jan 3 at 6:07











  • @user9437856 okay I just showed above the value and id both in alert. you can remove the id part.

    – Sayed Mohd Ali
    Jan 3 at 6:10











  • @user9437856 ok I got it what you are looking for try the above code and tell me what output you are getting.

    – Sayed Mohd Ali
    Jan 3 at 6:29














0












0








0







You can use onchange event in your HTML part of the code



$x=1;
foreach ($duration as $row) {?>
<input type="hidden" class="activeID" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" onchange="myfunction();" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>

<?php $x++;}


Here is the function



function myfunction () {
alert($(this).parent()); //what are you getting
alert($(this).parent().find(".activeID").value()); //what are you getting?
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
};





share|improve this answer















You can use onchange event in your HTML part of the code



$x=1;
foreach ($duration as $row) {?>
<input type="hidden" class="activeID" name="activeID" id="activeID<?php echo $x;?>" value="<?php echo $row->activity_name_id;?>">
<select name="Duration<?php echo $x;?>" onchange="myfunction();" class="form-control" id="Duration<?php echo $x;?>">
<option selected disabled >Select year</option>
<option value="12m" <?php if($row->Duration == '12m' ){ echo 'selected="selected"'; } ?>>1 Year</option>
<option value="6m" <?php if($row->Duration == '6m' ){ echo 'selected="selected"'; } ?>>6 months</option>
</select>
<div id="results<?php echo $x;?>"></div>

<?php $x++;}


Here is the function



function myfunction () {
alert($(this).parent()); //what are you getting
alert($(this).parent().find(".activeID").value()); //what are you getting?
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
};






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 6:26

























answered Jan 3 at 6:03









Sayed Mohd AliSayed Mohd Ali

1,5202520




1,5202520













  • I just want to know, how it will display the input field value in the alert?

    – user9437856
    Jan 3 at 6:07











  • @user9437856 okay I just showed above the value and id both in alert. you can remove the id part.

    – Sayed Mohd Ali
    Jan 3 at 6:10











  • @user9437856 ok I got it what you are looking for try the above code and tell me what output you are getting.

    – Sayed Mohd Ali
    Jan 3 at 6:29



















  • I just want to know, how it will display the input field value in the alert?

    – user9437856
    Jan 3 at 6:07











  • @user9437856 okay I just showed above the value and id both in alert. you can remove the id part.

    – Sayed Mohd Ali
    Jan 3 at 6:10











  • @user9437856 ok I got it what you are looking for try the above code and tell me what output you are getting.

    – Sayed Mohd Ali
    Jan 3 at 6:29

















I just want to know, how it will display the input field value in the alert?

– user9437856
Jan 3 at 6:07





I just want to know, how it will display the input field value in the alert?

– user9437856
Jan 3 at 6:07













@user9437856 okay I just showed above the value and id both in alert. you can remove the id part.

– Sayed Mohd Ali
Jan 3 at 6:10





@user9437856 okay I just showed above the value and id both in alert. you can remove the id part.

– Sayed Mohd Ali
Jan 3 at 6:10













@user9437856 ok I got it what you are looking for try the above code and tell me what output you are getting.

– Sayed Mohd Ali
Jan 3 at 6:29





@user9437856 ok I got it what you are looking for try the above code and tell me what output you are getting.

– Sayed Mohd Ali
Jan 3 at 6:29











-1

















$(".select").change(function(){
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
});

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
<h2>Form control: select</h2>
<p>The form below contains two dropdown menus (select lists):</p>
<form>
<div class="form-group">
<label for="sel1">Select list (select one):</label>
<select class="form-control select" id="Sell">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<label for="sel1-item">Select list sell item (select one):</label>
<select class="form-control select" id="Sell-item">
<option>car</option>
<option>bike</option>
<option>cycle</option>
<option>auto</option>
</select>
</div>
</form>
</div>

</body>
</html>








share|improve this answer
























  • I think you have to check my code again, You edited my code and remove the $x++ also you remove the PHP tags after foreach.

    – user9437856
    Jan 3 at 5:48











  • Also in your answer, you haven't use the input fields. I have input field inside foreach and I need that value.

    – user9437856
    Jan 3 at 5:51











  • I have just given the sample for jquery.

    – Cryptex Technologies
    Jan 3 at 5:52











  • That is not my issue, but thanks for the answer, Jquery which you shared that already in my code and that it working. I need input field value in the jquery and i.e. not in your answer.

    – user9437856
    Jan 3 at 5:57
















-1

















$(".select").change(function(){
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
});

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
<h2>Form control: select</h2>
<p>The form below contains two dropdown menus (select lists):</p>
<form>
<div class="form-group">
<label for="sel1">Select list (select one):</label>
<select class="form-control select" id="Sell">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<label for="sel1-item">Select list sell item (select one):</label>
<select class="form-control select" id="Sell-item">
<option>car</option>
<option>bike</option>
<option>cycle</option>
<option>auto</option>
</select>
</div>
</form>
</div>

</body>
</html>








share|improve this answer
























  • I think you have to check my code again, You edited my code and remove the $x++ also you remove the PHP tags after foreach.

    – user9437856
    Jan 3 at 5:48











  • Also in your answer, you haven't use the input fields. I have input field inside foreach and I need that value.

    – user9437856
    Jan 3 at 5:51











  • I have just given the sample for jquery.

    – Cryptex Technologies
    Jan 3 at 5:52











  • That is not my issue, but thanks for the answer, Jquery which you shared that already in my code and that it working. I need input field value in the jquery and i.e. not in your answer.

    – user9437856
    Jan 3 at 5:57














-1












-1








-1










$(".select").change(function(){
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
});

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
<h2>Form control: select</h2>
<p>The form below contains two dropdown menus (select lists):</p>
<form>
<div class="form-group">
<label for="sel1">Select list (select one):</label>
<select class="form-control select" id="Sell">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<label for="sel1-item">Select list sell item (select one):</label>
<select class="form-control select" id="Sell-item">
<option>car</option>
<option>bike</option>
<option>cycle</option>
<option>auto</option>
</select>
</div>
</form>
</div>

</body>
</html>








share|improve this answer
















$(".select").change(function(){
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
});

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
<h2>Form control: select</h2>
<p>The form below contains two dropdown menus (select lists):</p>
<form>
<div class="form-group">
<label for="sel1">Select list (select one):</label>
<select class="form-control select" id="Sell">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<label for="sel1-item">Select list sell item (select one):</label>
<select class="form-control select" id="Sell-item">
<option>car</option>
<option>bike</option>
<option>cycle</option>
<option>auto</option>
</select>
</div>
</form>
</div>

</body>
</html>








$(".select").change(function(){
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
});

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
<h2>Form control: select</h2>
<p>The form below contains two dropdown menus (select lists):</p>
<form>
<div class="form-group">
<label for="sel1">Select list (select one):</label>
<select class="form-control select" id="Sell">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<label for="sel1-item">Select list sell item (select one):</label>
<select class="form-control select" id="Sell-item">
<option>car</option>
<option>bike</option>
<option>cycle</option>
<option>auto</option>
</select>
</div>
</form>
</div>

</body>
</html>





$(".select").change(function(){
alert("Id of the select box is "+ this.id);
alert("Value of the select box is "+this.value );
});

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
<h2>Form control: select</h2>
<p>The form below contains two dropdown menus (select lists):</p>
<form>
<div class="form-group">
<label for="sel1">Select list (select one):</label>
<select class="form-control select" id="Sell">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<label for="sel1-item">Select list sell item (select one):</label>
<select class="form-control select" id="Sell-item">
<option>car</option>
<option>bike</option>
<option>cycle</option>
<option>auto</option>
</select>
</div>
</form>
</div>

</body>
</html>






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 5:26









Cryptex TechnologiesCryptex Technologies

810213




810213













  • I think you have to check my code again, You edited my code and remove the $x++ also you remove the PHP tags after foreach.

    – user9437856
    Jan 3 at 5:48











  • Also in your answer, you haven't use the input fields. I have input field inside foreach and I need that value.

    – user9437856
    Jan 3 at 5:51











  • I have just given the sample for jquery.

    – Cryptex Technologies
    Jan 3 at 5:52











  • That is not my issue, but thanks for the answer, Jquery which you shared that already in my code and that it working. I need input field value in the jquery and i.e. not in your answer.

    – user9437856
    Jan 3 at 5:57



















  • I think you have to check my code again, You edited my code and remove the $x++ also you remove the PHP tags after foreach.

    – user9437856
    Jan 3 at 5:48











  • Also in your answer, you haven't use the input fields. I have input field inside foreach and I need that value.

    – user9437856
    Jan 3 at 5:51











  • I have just given the sample for jquery.

    – Cryptex Technologies
    Jan 3 at 5:52











  • That is not my issue, but thanks for the answer, Jquery which you shared that already in my code and that it working. I need input field value in the jquery and i.e. not in your answer.

    – user9437856
    Jan 3 at 5:57

















I think you have to check my code again, You edited my code and remove the $x++ also you remove the PHP tags after foreach.

– user9437856
Jan 3 at 5:48





I think you have to check my code again, You edited my code and remove the $x++ also you remove the PHP tags after foreach.

– user9437856
Jan 3 at 5:48













Also in your answer, you haven't use the input fields. I have input field inside foreach and I need that value.

– user9437856
Jan 3 at 5:51





Also in your answer, you haven't use the input fields. I have input field inside foreach and I need that value.

– user9437856
Jan 3 at 5:51













I have just given the sample for jquery.

– Cryptex Technologies
Jan 3 at 5:52





I have just given the sample for jquery.

– Cryptex Technologies
Jan 3 at 5:52













That is not my issue, but thanks for the answer, Jquery which you shared that already in my code and that it working. I need input field value in the jquery and i.e. not in your answer.

– user9437856
Jan 3 at 5:57





That is not my issue, but thanks for the answer, Jquery which you shared that already in my code and that it working. I need input field value in the jquery and i.e. not in your answer.

– user9437856
Jan 3 at 5:57


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016681%2fhow-do-i-pass-the-id-value-to-the-function%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith