PDA

View Full Version : Help with alert message


netmon22
05-21-2003, 05:55 AM
Ive been working on this script and running into problems. Its my 2nd week in JS.

Problem- I need to know how get a alert box when I finish the form and hit the "ENTER" button. I need the alert box to put certain fields that were completed during the form.

Example: inside the alert box, with the answers on seperate lines
if possible.

(Name entered for employee name)
(Which Department they work in)
(Take home pay)

script-

<html>
<head>
<script>
function calcMe() {
document.form1.salary.value=document.form1.menu.value;
}
function calcMe2() {
document.form1.overtimepay.value=document.form1.salary.value*.025*document.form1.overtime.value*1.5;
document.form1.takehomepay.value=document.form1.salary.value*1 + document.form1.overtimepay.value*1;
alert(document.form1.employee.value + ", " + document.form1.menu.value);
}

</script>
</head>
<body>
<h3>Employee Cost Calculator</h3>
<p>

<form name="form1">
Employee Name - <input type="text" value="" name="employee">
<p>
Overtime hours -
<input type="number" size="4" name="overtime">
<p>
<SELECT NAME="menu" onChange="calcMe()">
<option value="Which Department are you in."> Which department are you in?
<OPTION VALUE="900" name="sales">Sales Department
<OPTION VALUE="350" name="support">Support Department
<OPTION VALUE="600" name="technical">Technical Department
</SELECT>
<p>Salary - $ <input type="number" size="12" name="salary"></p>
Overtime pay - $ <input type="number" size="6" name="overtimepay">

<p>
Take home pay -$
<input type="number" size="" name="takehomepay">
<input type="button" value="enter" name="ta" onClick="calcMe2()">
</p>
</form>
</body>
</html>


You dont know how much you'll help me

Thanks,
Chris

A1ien51
05-21-2003, 06:17 AM
to get seperate line you need to use this \n

alert("The First \n The Second \n The Third");

with variables

var first="1st"
var sec="2nd"

alert("The "+first" \n The "+sec);

Hope that helps