Is there any way to reduce these lines of code?
var url = window.location.href.split("?");
if(url[1].toLowerCase().includes("chk=webdes-check")){
$('#website-design').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=webdev-check")){
$('#website-development').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=webmain-check")){
$('#website-maintenance').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=seo-check")){
$('#search-engine-optimisation').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=softdev-check")){
$('#software-development').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=digmark-check")){
$('#digital-marketing').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=digstrats-check")){
$('#digital-strategy').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=digbrand-check")){
$('#digital-branding').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=anivid-check")){
$('#animated-videos').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=virtreal-check")){
$('#3d-virtual-reality').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=augreal-check")){
$('#augmented-reality').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=hostdom-check")){
$('#hosting-and-domain').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=appdevuiuxexp-check")){
$('#app-development').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=reprev-check")){
$('#reputation-review').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=incgen-check")){
$('#income-generating').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=datacol-check")){
$('#database-collection').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=telcom-check")){
$('#tel-communication').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=humres-check")){
$('#human-resources').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=vidprod-check")){
$('#video-production').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=aiweb-check")){
$('#ai-for-website').attr('checked', true);
}
else if(url[1].toLowerCase().includes("chk=telestrats-check")){
$('#telemarketing-and-stategy').attr('checked', true);
}
else{
//false
}
I just wanted to shorten this code because i know it's not proper. Should I use a for loop maybe? I'm not sure how.
and by the way this is how i call it just forgot it earlier
function linkPageContact(clicked_id){
if(clicked_id === 'website-design-check'){
window.location.href = "/contact?chk=webdes-check";
}
else if(clicked_id === 'website-development-check'){
window.location.href = "/contact?chk=webdev-check";
}
else if(clicked_id === 'website-maintenance-check'){
window.location.href = "/contact?chk=webmain-check";
}
else if(clicked_id === 'search-engine-optimization-check'){
window.location.href = "/contact?chk=seo-check";
}
else if(clicked_id === 'software-development-check'){
window.location.href = "/contact?chk=softdev-check";
}
else if(clicked_id === 'digital-marketing-check'){
window.location.href = "/contact?chk=digmark-check";
}
else if(clicked_id === 'digital-strategy-check'){
window.location.href = "/contact?chk=digstrats-check";
}
else if(clicked_id === 'digital-branding-check'){
window.location.href = "/contact?chk=digbrand-check";
}
else if(clicked_id === 'animated-videos-check'){
window.location.href = "/contact?chk=anivid-check";
}
else if(clicked_id === 'virtual-reality-3d-check'){
window.location.href = "/contact?chk=virtreal-check";
}
else if(clicked_id ==="augmented-reality-check"){
window.location.href = "/contact?chk=augreal-check";
}
else if(clicked_id ==="hosting-and-domain-check"){
window.location.href = "/contact?chk=hostdom-check";
}
else if(clicked_id ==="app-dev-uiux-experience-check"){
window.location.href = "/contact?chk=appdevuiuxexp-check";
}
else if(clicked_id ==="reputation-review-check"){
window.location.href = "/contact?chk=reprev-check";
}
else if(clicked_id ==="income-generating-check"){
window.location.href = "/contact?chk=incgen-check";
}
else if(clicked_id ==="database-collection-check"){
window.location.href = "/contact?chk=datacol-check";
}
else if(clicked_id ==="tel-communication-check"){
window.location.href = "/contact?chk=telcom-check";
}
else if(clicked_id ==="human-resources-check"){
window.location.href = "/contact?chk=humres-check";
}
else if(clicked_id ==="video-production-check"){
window.location.href = "/contact?chk=vidprod-check";
}
else if(clicked_id ==="ai-for-websites-check"){
window.location.href = "/contact?chk=aiweb-check";
}
else if(clicked_id ==="telemarketing-strategy-check"){
window.location.href = "/contact?chk=telestrats-check";
}
// window.location.href = "/contact";
// alert(clicked_id);
}