Several conditions to "if' statement [closed] - javascript

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 days ago.
Improve this question
I wanted to add the same button at the end of all my posts (Wordpress site), so I added this code which worked perfectly:
add_action('x_before_the_content_end', function() {
if(is_singular( 'post' ) ) {
echo do_shortcode('[button type=”transparent” shape=”rounded” size=”jumbo” href=https://miracle-z.com/category/blogue-miracle-z/ title=Continuer]Continuer la lecture[/button]');
}
});
Then I tried to add another condition, so it would apply only to French pages.
So I added this:
add_action('x_before_the_content_end', function() {
if(ICL_LANGUAGE_CODE=='fr_FR' || is_singular( 'post' ) ) {
echo do_shortcode('[button type=”transparent” shape=”rounded” size=”jumbo” href=https://miracle-z.com/category/blogue-miracle-z/ title=Continuer]Continuer la lecture[/button]');
}
});
...but the button appears in all languages in all my posts...
What am I doing wrong?

Related

How to remove underscores from a string array in typescript-angular project? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 months ago.
Improve this question
i want to replace all the "_" occurrences from an array like this (TASK_1,TASK_2,TASK_3).
I receive this from the back-end and i cannot use the replace all because the project doesn't support es2021. I need to display the array like this (TASK 1,TASK 2, TASK 3).
I tried this method:
formatWithoutUnderScore(valueToFormat:any) {
return valueToFormat.map((value:any) => value.replace(/_/g, ' '));
}
and the used it:
this.formatWithoutUnderScore(this.totalTasks);
But it does nothing :(
Can someone help?
this.totalTasks = this.formatWithoutUnderScore(this.totalTasks);

Req.params undefined [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 months ago.
Improve this question
So i have this code
router.get('/invite/:invitecode', async(res,req) => {
return console.log(req.params)
if(!req.params.invitecode) {
return res.render('404')
}
if(!req.user) {
res.redirect(`/login?state=invite/${req.params.invitecode}`)
} else {
res.render('join')
}
})
And when I go to
http://localhost:3000/invite/fs
It is supposed to return fs as a param, but instead, it console.logs undefined
Why is this happening?
It does not work because you are accessing the Response object, you should flip the arguments
from:
async(res,req)
to
async(req,res)

Redirect to new page after form submition [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
How do i redirect to another page after form submition. This is my code:
form.addEventListener("submit", function (e) {
e.preventDefault;
console.log("sasadas")
mal = {
"omkrets": form.omkrets.value,
"areal": form.areal.value,
"hoyde": form.hoyde.value,
}
document.cookie = 'mal=' + JSON.stringify(mal) + ";domain=;path=/";
window.location.href = "http://127.0.0.1:8000/kategori/";
})
I've tried window.location.href but doesn't work. Any ideas? I've searched around but didn't find a definitive answer.
Just replace,
e.preventDefault;
by
e.preventDefault();

If and else statement in Javascript is not working [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
want to run this javascript when there the button is clicked, if errors on the form check if statement and stop, if no errors execute the else statement......
$(document).ready(function () {
$('#continueToAttachments').on('click', function() { //on click button
if ($("#cevent").valid() = false) { // if errors stop the user from moving forward
return;
} else { // expecting this to run if there are no errors in the form
$('#Event-Information').removeClass('w--tab-active');
$('#Attachments').addClass('w--tab-active');
$('#Event-Information-Tab').removeClass('w--current');
$('#Attachments-Tab').addClass('w--current');
}
});
});
To check if a value is equal another you should use == or === to check if the variables are the same type too. = is for attribution.
if ($("#cevent").valid() == false)

If/else statements not displaying correctly to console [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I'm trying to get the console to read "No goal!" but every time I run it, I get "Goal". I'm guessing there's some basic syntax error that I'm making?
let isSoccerFan = false;
if (isSoccerFan=true) {
console.log("Goal!");
} else{
console.log("No goal!")
}
Your code is not correct. Try this:
let isSoccerFan = false;
if (isSoccerFan) {
console.log('Goal!');
} else {
console.log('No goal!');
}

Categories