Here I have used jQuery. This code gives me output but I want output in a different way.
When I enter 5 digits in the input field, it gives me "one" in the select tag and "one, two, and four" in the p tag as my output.
Can I get like this if I click on "two" in the p tag, the value in the select tag should change into two? Can someone help me out?
What I have tried:
jQuery(document).keyup(function(){
jQuery("#txtFirstNo").on("input", function() {
jQuery("#selResult").val("");
var arr = [];
if ( jQuery(this).val().match(/^(\d{5})$/, '') ) {
jQuery("#selResult").val("one");
}
else if ( jQuery(this).val().match(/^(\d{5})$/, '') ) {
jQuery("#selResult").val("two");
}
else if ( jQuery(this).val().match(/^(\d{5})$/, '') ) {
jQuery("#selResult").val("four");
}
else if ( jQuery(this).val().match(/^(\d{7})$/, '') ) {
jQuery("#selResult").val("three");
}
if (jQuery("#txtFirstNo").val().match(/^\d{5}$/, '') ) {
arr.push("one") ;
}
if ( jQuery("#txtFirstNo").val().match(/^\d{5}$/, ''))
{
arr.push("two");
}
if ( jQuery("#txtFirstNo").val().match(/^\d{5}$/, ''))
{
arr.push("four");
}
if ( jQuery("#txtFirstNo").val().match(/^\d{7}$/, ''))
{
arr.push("three");
}
jQuery("#txtPrint").html(arr.join("<br/>"));
arr=[];
});
});
<br> Tracking Number :
<br>
Shipping Carriers :
Select Carriers
one
two
three
four
<p id="txtPrint"></p>