Link to home
Create AccountLog in
Avatar of StewSupport
StewSupport

asked on

popup

i have a contact page that let people type in question and comment and a submit button to submit the comment. is therea way in javascript to have a popup that loop through all of the fields and display whatever fields have values in that popup. and inside the popup has a continue or cancel button? if they hit continue, submit the form, if they hit cancel return false on the page? thank you.
Avatar of tring_tring
tring_tring
Flag of United States of America image

You can use Javascript confirm box. For instance you can use it like:-

var abc = confirm('the Contact values are ' + kkr + ' .do u wish to continue');
if (abc==true){
//Do something
} else {
//Do something
}

Avatar of StewSupport
StewSupport

ASKER

i know about confirm button, but this doesn't display html, and the button are ok or cancel, not yes or no.
Did you considered using modal popup\window?
thought about that but i have to do extra steps, thinking i could get away with popup
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
your isn't a form and my is a form so when i click on it it display for a few second and goes away. so i changed my submit button to just a regular button and do form submit later. i hope this is ok. what do you think? on another question how do i make the popup stay center all the time? thanks
You need to wait for confirmation from the user before you submit, so, yes, you want to use a regular button and submit after validating and cleaning the user input. Never trust user input. It could contain malicious code. In your button onclick attribute write onclick="return validateInput(); return false;". Create some javascript code to validate the input, then return true if valid, false if not to prevent submit.

Centering the popup in a container will depend on your situation, but generally you adjust the css to set the margins to "auto" for the container you want to center the popup in.