new bug in java script ! help me pls

hello
26 Replies
NIMA
NIMAOPā€¢8mo ago
<script>
function lengthonkey(){
document.getElementById('qpq').innerHTML = document.getElementById('numba').value.length ;



}



</script>
<script>
function lengthonkey(){
document.getElementById('qpq').innerHTML = document.getElementById('numba').value.length ;



}



</script>

<div class="borderinput1 flexbox " >

<div> <input type="number" class="input1" id="numba" placeholder="enter ur number" required onkeyup="lengthonkey()" > </div>
<div> <button class="chichiflex" id="qpq" > </button> </div>


</div>

<div class="borderinput1 flexbox " >

<div> <input type="number" class="input1" id="numba" placeholder="enter ur number" required onkeyup="lengthonkey()" > </div>
<div> <button class="chichiflex" id="qpq" > </button> </div>


</div>
how can i do something when i still dont put anything in my input the button be invisibel and when i put value in input button pop on ?
dys šŸ™
dys šŸ™ā€¢8mo ago
Try <button>Button Text</button>.
NIMA
NIMAOPā€¢8mo ago
? im not talking about thath
dys šŸ™
dys šŸ™ā€¢8mo ago
You want the button to always be visible?
NIMA
NIMAOPā€¢8mo ago
not when i enter a vlue get visibel and when no value in it get disbel u know what i mean now?
dys šŸ™
dys šŸ™ā€¢8mo ago
Something like this?
lko
lkoā€¢8mo ago
@NIMA the problems you had these couple of days were pretty simple, I suggest you to start from a html tutorial, then watch one of css and one of js, so you'll have better basics overall, and you'll be able to fix most problems by yourself
NIMA
NIMAOPā€¢8mo ago
šŸ˜” yes it was this this is not my yestday problem ? ! tnx so much my only problem is in js not html css and cuse im start learning js in 4 day
lko
lkoā€¢8mo ago
Then you probably would have known that you could have done it with css
NIMA
NIMAOPā€¢8mo ago
yes but i want do thath with js most of thing can do with css too but im i want try java script to learn it fully
lko
lkoā€¢8mo ago
ok
NIMA
NIMAOPā€¢8mo ago
not work in my code i do this with if and else and i got this problem qpq.style.visibility = length === 0 ? 'hidden' : 'visible' not work oh it was for lengthonkey() what is lengthonkey() in end mean?
lko
lkoā€¢8mo ago
it calls the function
NIMA
NIMAOPā€¢8mo ago
2 times?
lko
lkoā€¢8mo ago
No
function idk() { // declaring the function
...
}

idk() // calling it
function idk() { // declaring the function
...
}

idk() // calling it
NIMA
NIMAOPā€¢8mo ago
hmm so what on click do ? its gonna call him ? ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh there is no onclick thats why šŸ¤”
lko
lkoā€¢8mo ago
there's a keyup, which is basically the same thing, it still calls the function
NIMA
NIMAOPā€¢8mo ago
so if keyup do thath why it need recalls
lko
lkoā€¢8mo ago
but you have to call the function when the page loads because you have to hide the button first
Jochem
Jochemā€¢8mo ago
I'd recommend reading something like https://javascript.info, it will explain javascript in great detail, starting from the very basics
NIMA
NIMAOPā€¢8mo ago
ok tnx 'hidden' : 'visible' hidden is first one right? i mean when website load it gonna read hidden first? thaths why funcshen gonna hide it?
lko
lkoā€¢8mo ago
this: condition ? a : b means
if(condition) {
a
} else {
b
}
if(condition) {
a
} else {
b
}
So, if is empty, hide it
NIMA
NIMAOPā€¢8mo ago
ok i undestand tnx for help
<script>
function lengthonkey(){
let length = document.getElementById('numba').value.length
let qpq = document.getElementById('qpq')
qpq.innerHTML = length
if(length ==0 ){
qpq.style.visibility ='hidden';

}else{
qpq.style.visibility ='visible';
}

}
lengthonkey()


</script>
<script>
function lengthonkey(){
let length = document.getElementById('numba').value.length
let qpq = document.getElementById('qpq')
qpq.innerHTML = length
if(length ==0 ){
qpq.style.visibility ='hidden';

}else{
qpq.style.visibility ='visible';
}

}
lengthonkey()


</script>
this is correct too ? i get the same asnwer but i want to know is this good thing to wright like this or no
lko
lkoā€¢8mo ago
yeah it's fine
13eck
13eckā€¢8mo ago
@NIMA next time you make a post, please give it a well-thought out title. "New Bug" is very generic and not helpful for anyone reading it. Please remember that this forum is not only for you to get assistance but for others who might have the same issues can easily find existing solutions.
NIMA
NIMAOPā€¢8mo ago
aright sorry šŸ˜‚
Want results from more Discord servers?
Add your server