Reputation: 187
I have an simple question,
How to change
window.alert ('Please input data into the \"Part No.\" field.');
to be just text, no alert
Please input data into the \"Part No.\" field.
Upvotes: 1
Views: 788
Reputation: 16325
I assume you want to simply write it to your document? Include this in a <script>
block in your <body>
document.write('<p>Please input data into the "Part No." field.</p>');
EDIT: On rethinking this, I now believe that you want the message to appear after the input element. Here, assuming your input element is <input id="part_no_field" />
// Create a message node
var messageNode = document.createElement('p');
messageNode.innerText = 'Please input data into the "Part No." field.';
// Find your "part number" field
var partField = document.getElementById('part_no_field');
// Append the message node after your "part number" field
if (partField.nextSibling) {
partField.parentNode.insertBefore(messageNode, partField.nextSibling);
} else {
partField.parentNode.appendChild(messageNode);
}
Upvotes: 1
Reputation: 11805
It depends where you want the text to be placed:
var text = 'Please input data into the \'Part No.\' field.'
//inside a div
div.innerHTML = text;
//the bottom of the body
document.body.innerHTML+=text;
//an input field
input.value = text;
//rewriting the document
document.open();
document.write(text);
document.close();
Upvotes: 1