Community » Forum » Feedback » Developer Community

First ... 7 8 9 10 11 ... Last
spacetinker   VIP
Mogul
USD 105 340.71
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   VIP
Mogul
USD 382 129.45
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   VIP
Mogul
USD 105 340.71
i wanted to change the text when the button was clicked
masterplayer833   VIP
Mogul
USD 382 129.45
Oh, make button be:
<button id="myButton" onclick="changeText()">Button Text</button>
<script>
function changeText(){
document.getElementById("myButton").innerHTML = "New Textt";
}
</script>
spacetinker   VIP
Mogul
USD 105 340.71
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   VIP
Mogul
USD 382 129.45
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   VIP
Mogul
USD 105 340.71
i thought it was byld not byid that might explain the problrem im having
masterplayer833   VIP
Mogul
USD 382 129.45
js and most languages are case sensitive. It is document.getElementById
spacetinker   VIP
Mogul
USD 105 340.71
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   VIP
Mogul
USD 382 129.45
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