Community » Forum » Feedback » Developer Community

spacetinker
Businessman   VIP
is this code alright?
<script>
var b;
jsfunction(a)
var b = "yes";
</script>
<html>
<heading>
<p>
<b></b>
testing stuff
</p>
</heading>
<body>
<button onclick="jsfunction(a)">
hi this is a button
</button>
</body>
</html>
masterplayer833
Businessman   VIP
The testing stuff will not be bold as it is not in the tags. The js script is in the right tag, bu is not written properly, if you want to log the word yes every time the button is clicked you could do this (jsfunction could be anything).:
<script>
function jsfunction(a){
console.log("Yes");
}
</script>
spacetinker
Businessman   VIP
i wanted to change the text when the button was clicked
masterplayer833
Businessman   VIP
Oh, make button be:
<button id="myButton" onclick="changeText()">Button Text</button>
<script>
function changeText(){
document.getElementById("myButton").innerHTML = "New Textt";
}
</script>
spacetinker
Businessman   VIP
so .innerhtml reloads the code to alter the webpage? and to alter a button it needs to have a id? also what is blyd?
masterplayer833
Businessman   VIP
byid lets you select an element by its id, and .innerHTML is what is in between the tags, like: <p>This is the .innerHTML</p>
spacetinker
Businessman   VIP
i thought it was byld not byid that might explain the problrem im having
masterplayer833
Businessman   VIP
js and most languages are case sensitive. It is document.getElementById
spacetinker
Businessman   VIP
okay i think i can start on a simple calculator
i just have three questions

1. how can i input a full number for example in a text input?

2. how can i make things like boxes on a screen?

3. can i like remove buttons and boxes temporarily during the program?
masterplayer833
Businessman   VIP
number input:
<input type="number" id="anid"></input>

<script>
var number = document.getElementById("anid").value;
</script>

What do you man by boxes?

to disable a button:
<button id="disabledButton"></button>
<script>
// to disable
document.getElementById("disabledButton").disabled = true;
//to enable
document.getElementById("disabledButton").disabled = false;

</script>
First ... 7 8 9 10 11 ... Last