Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

JavaScript alert with input field

Posted on 2004-09-27
7
2,603 Views
Last Modified: 2012-05-05
Hi Experts,

Is there away to put an input field in an alert box, or some type of message box, and then verify if information has been entered before continuing to the page that updates the db?

I have a menu option, text link, when selected I want an alert box to pop and asks for a date to be entered in the input field - then verify a valid date has been entered before continuing to the asp page that updates my SQL server db.

If this can't be done in JavaScript can it be done in asp?

Thanks!
0
Comment
Question by:one2goofy
7 Comments
 
LVL 6

Expert Comment

by:viola123
ID: 12166149
hi,

unfortunately, alert box is a built-in function. it is impossible to add a text field in alert message box.

i am suggesting you implementing a text field and button in a <div> layer and then toggle the visibility of this <div.layer via your menu option.

cheers
viola
0
 

Author Comment

by:one2goofy
ID: 12166165
Is there any other way to pop up a box?  If not an alert any other message box that allows input fields?
0
 
LVL 14

Expert Comment

by:Esopo
ID: 12166213
You can always create your own pop-up windows (given the user doesn't have pop-up blocking ;)

http://www.htmlcodetutorial.com/linking/linking_famsupp_72.html
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 6

Expert Comment

by:viola123
ID: 12166232
hi,

i don't think there is any way to append a text field in a message box.

however, another normal walk-around is to create a small centralized window, which is able to hold your textbox and button.

eg.
if (confirm("Proceed?")) {
           window.location = "newStatusPage.html";
           newWindow =   window.open("http://www.google.com", "newWindow", "height=400, width=400");      
           newWindow.focus();
}

good luck

viola
0
 
LVL 5

Accepted Solution

by:
pmsyyz earned 500 total points
ID: 12166281
Use prompt()

prompt(message, default) -- prompts the user with a question, message, and a text entry box where they can type an answer.  The default parameter is the initial value in the text entry box.  If the user presses the OK button, the text in the text entry box is returned by the function.  If the user chooses the Cancel button, the function returns the empty string.

var x=prompt('Question?','');
if (x) { ...whatever...}
0
 
LVL 6

Expert Comment

by:viola123
ID: 12166319
pmsyyz,

good idea, but do you have any way to customize the promp box further? it yes, that would be great for one2goofy


viola
0
 
LVL 5

Expert Comment

by:pmsyyz
ID: 12186848
No, you can't really customize it, the most you can do is add newlines (\n) to your message text.

For more format control I would use a text INPUT in a DIV with a higher z-index than the page and style it with CSS.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question