• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved HTML and Javascript

Status
Not open for further replies.

Wavoz

Oldschooler
Joined
Jul 10, 2011
Messages
1,021
Reaction score
84
Not sure if it's the right place to post, but i need some help asap.
I need to help out friend with some basic HTML and javascript website or he gets kicked from University....

So i need a prompt box to ask name and greet the person with that name...
Code:
<script>
function myFunction()
{
var x;

var name=prompt("Please enter your name","Your name");

if (name!=null)
  {
  x="Hello " + name + "! How are you today?";
  document.getElementById("demo").innerHTML=x;
  }
}
</script>

I know how it works with button "<button onclick=" but what is the function for "on visit"?
I need the prompt box to pop up when site is first opened, not by clicking the button...
 
Code:
<!DOCTYPE html>
<html>
<body [COLOR=#ff0000]onload[/COLOR]="myFunction()">

<p>Click the button to demonstrate the prompt box.</p>

<p id="demo"></p>

<script>
function myFunction()
{
var x;

var name=prompt("Please enter your name","Harry Potter");

if (name!=null)
  {
  x="Hello " + name + "! How are you today?";
  document.getElementById("demo").innerHTML=x;
  }
}
</script>

</body>
</html>
Here you go.

Source: w3schools
 
Thank you, that was really easy :o

I learned this 3 years ago and i can't remember anything, i became curious and now i am thinking about taking a course :p

rep

- - - Updated - - -

okay, another simple problem that seems difficult for me :D
1.png


The first page containts info about ros and columns:
Code:
<frameset rows="20%,*"> 
     <frame name="header" src="row1.html"> 
     <frameset cols="20%,*"> 
     <frame name="left" src="col1.html"> 
     <frame name="right" src="col2.html"> 
     </frameset> 
</frameset>

So i want the main stuff to be in the col2 only (so i put the script in col2.html) but it also appears on the header row....
col2
Code:
<html>
<body onload="myFunction()">


<p id="demo"></p>

<script>
function myFunction()
{
var x;

var name=prompt("Palun sisestage oma nimi","Nimi");

if (name!=null)
  {
  x="Tere " + name + "! Kuidas läheb?";
  document.getElementById("demo").innerHTML=x;
  }
}
</script>
<script type="text/javascript"> 
var dt= new Date();
document.write(dt.toLocaleString());
</script>


</body>
</html>

i don't understand, the frameset can't be in html part and if its outside the html part then the html part doesn't function....

- - - Updated - - -

Solved everything out on my own by reading tons of tutorials and examples :D

Can be closed.
 
Last edited:
Status
Not open for further replies.
Back
Top