Output problem

Hi.

I have a script with two variables. I need both outputs on separate lines.

The first line should read: Receipt required at: "15:15"
The second line should read: Receipt required at: "15:15" and at "20:15" before close

I'm having troubles with the code below in outputting both lines on separate lines, and adding inverted commas to the time variable.

<font font size="4" face="verdana" color="blue">Requester</font><p>
<p><input type="text" id="a" value="15:15"></p>
<p><input type="text" id="b" value="20:15"></p>
<p><font font size="2" face="verdana" color="blue">Click "generate" for response...</font></p>
<button onClick="myFunction()">Generate</button>
<p id="Request"></p>
<script>
function myFunction() {
    var a = document.getElementById("a").value;
    document.getElementById("Request").innerHTML = "<span style='color: grey;font-size: 75%;font-family: verdana;'>Receipt required at: '" + a + "'"
    var a = document.getElementById("a").value;
    document.getElementById("Request").innerHTML = "<span style='color: grey;font-size: 75%;font-family: verdana;'>Receipt required at: '" + a + "' and at + b+ "before close"
}
</script>

Open in new window

Mike DiasAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
See if this helps, you had a few syntax errors.

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
function myFunction() {
    var a = document.getElementById("a").value;
    var pText = "<span style='color: grey;font-size: 75%;font-family: verdana;'>Receipt required at: '" + a + "'</span>";
    var b = document.getElementById("b").value;
    pText = pText + "</br><span style='color: grey;font-size: 75%;font-family: verdana;'>Receipt required at: '" + a + "' and at '" + b + " before close</span>";
    document.getElementById("Request").innerHTML = pText
}
</script>

<font font size="4" face="verdana" color="blue">Requester</font><p>
<p><input type="text" id="a" value="15:15"></p>
<p><input type="text" id="b" value="20:15"></p>
<p><font font size="2" face="verdana" color="blue">Click "generate" for response...</font></p>
<button onClick="myFunction()">Generate</button>
<p id="Request"></p>
</body>
</html>

Open in new window


»bp

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike DiasAuthor Commented:
This works well.
I notice pText in the code. Is this the method to adding more lines, if I need to?
Bill PrewIT / Software Engineering ConsultantCommented:
It's just a variable I created to hold all the text you wanted to put in that paragraph.  The break between the two lines is accomplished with the </br> tag.


»bp
Mike DiasAuthor Commented:
Good explanation and works.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.