I have a dropdown box created in php within html the value of the dropdown box is concatenated example: <?php echo $consignees['consigneename']; ?>
<?php echo "-"; ?>
<?php echo $consignees['city']; ?><?php echo ", "; ?>
<?php echo $consignees['state']; >
When I run this javascript to retrieve the text from the box I get a return but it's spread out like this:
ADM PROTEIN SPECIAL - DECATUR, IL
Should be like this: adm protein special-Decatur, il
Perhaps if I build a global variable at the time of the selection using the three fields the result would be correct(just a guess). I don't know how to do this even to test it.
Any method that works would be appreciated. I'm still a newbie and learning everyday. It seems easy but can't get a handle on it. If my dropdown was two columns (index and text) it works fine but because of the concatenated there is this issue.
My script is:
$("#consigneeBtn").on('click', function() {
varconsignee = document.getElementById('consignee').value;
varconsigneetext= $('#consignee').find(':selected').text();
document.getElementById("consigneename").value = varconsigneetext;
});
I'm attempting to retrieve the selected text for dropdown 'consignee' and putting it in different textbox named 'consigneename'
Thank you
<?php echo "-"; ?>
<?php echo $consignees['city']; ?><?php echo ", "; ?>
<?php echo $consignees['state']; >
When I run this javascript to retrieve the text from the box I get a return but it's spread out like this:
ADM PROTEIN SPECIAL - DECATUR, IL
Should be like this: adm protein special-Decatur, il
Perhaps if I build a global variable at the time of the selection using the three fields the result would be correct(just a guess). I don't know how to do this even to test it.
Any method that works would be appreciated. I'm still a newbie and learning everyday. It seems easy but can't get a handle on it. If my dropdown was two columns (index and text) it works fine but because of the concatenated there is this issue.
My script is:
$("#consigneeBtn").on('click', function() {
varconsignee = document.getElementById('consignee').value;
varconsigneetext= $('#consignee').find(':selected').text();
document.getElementById("consigneename").value = varconsigneetext;
});
I'm attempting to retrieve the selected text for dropdown 'consignee' and putting it in different textbox named 'consigneename'
Thank you