0
<html>
<head>
  <meta charset="utf-8">
  <script>
    function test(){
      var name = document.getElementById('name').value;
      var snumber = document.getElementById('snumber').value;
      document.write("name="+name+"");
      document.write("&snumber="+snumber+"<br />");
    }
  </script>
</head>

<body>
   <h2>Example of sending data using POST</h2>
     Name :
   <input type="text" id="name"><br/>
     Student number:
   <input type="text" id="snumber"><br/><br/>
   <input type="button" value="submit" onclick="test();">
</body>
</html>

I want to change the font size of 6th and 7th lines' result to h2 size I can change in body section by putting

 <h2></h2> 

however, it's not working in a script section. If I input data in name and snumber section, It connects to a new page that shows inputs like "name=David&snum=21467564" I want this font size to be h2 size!

6 Answers 6

1

Simply add h2 tag

Single line output:

function test(){
      var name = document.getElementById('name').value;
      var snumber = document.getElementById('snumber').value;
    
 document.write("<h2>name="+name+"");
 document.write("&snumber="+snumber+"</h2> <br/>");
 }
<h2>Example of sending data using POST</h2>
     Name :
   <input type="text" id="name"><br/>
     Student number:
   <input type="text" id="snumber"><br/><br/>
   <input type="button" value="submit" onclick="test();">

For multiline output: Just close <h2> tag and start new heading tag like:

document.write("<h2>name="+name+"</h2>");
document.write("<h2>snumber="+snumber+"</h2><br />");
Sign up to request clarification or add additional context in comments.

Comments

1
    var name = document.getElementById('name').value;
    name= "<span style='font-size:32px;'>"+name+"</span>";
    snumber= "<span style='font-size:32px;'>"+snumber+"</span>";
    var snumber = document.getElementById('snumber').value;
    document.write("name="+name+"");
    document.write("&snumber="+snumber+"<br />");

Comments

0

you can do something like this:

<script>
function test(){
 var name = document.getElementById('name').value;
 var snumber = document.getElementById('snumber').value;
 document.write("<h2>name="+name+"</h2>");
 document.write("<h2>&snumber="+snumber+"</h2><br />");
}
</script>

Comments

0

Simple! just add h2 element.

function test(){
 var name = document.getElementById('name').value;
 var snumber = document.getElementById('snumber').value;
 document.write("<h2>name="+name+"</h2>");
 document.write("<h2>&snumber="+snumber+"</h2>");
}
<h2>Example of sending data using POST</h2>
Name :
<input type="text" id="name"><br/>
Student number:
<input type="text" id="snumber"><br/><br/>
<input type="button" value="submit" onclick="test();">

Comments

0

try this one

function test(){
 var name = document.getElementById('name').value;
 var snumber = document.getElementById('snumber').value;
 document.write("<h2>name="+name+"</h2>");
 document.write("<h2>snumber="+snumber+"</h2><br />");
}
<h2>Example of sending data using POST</h2>
Name :
<input type="text" id="name"><br/>
Student number:
<input type="text" id="snumber"><br/><br/>
<input type="button" value="submit" onclick="test();">

Comments

0

function test(){
      var name = document.getElementById('name').value;
      var snumber = document.getElementById('snumber').value;
    
 document.write("<h2>name="+name+"</h2>");
 document.write("<h2>&snumber="+snumber+"</h2> <br/>");
 }
<h2>Example of sending data using POST</h2>
     Name :
   <input type="text" id="name"><br/>
     Student number:
   <input type="text" id="snumber"><br/><br/>
   <input type="button" value="submit" onclick="test();">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.