Jump to content

Javascript Popup


socalnate

Recommended Posts

Javascript noobie here.  So I'm working on form validation and I'm simply adding up all the input data and checking to make sure it equals 100.  If it doesn't, then I want a popup and to focus on the div container enclosing the inputs "Sum Must Equal 100 Percent."  How do I get the popup to popup?  Here's what I got so far:

<script type='text/javascript'>
// Make quick references to our fields
var action_percent = document.getElementById('action_percent');
var adventure_percent = document.getElementById('adventure_percent');
var animation_percent = document.getElementById('animation_percent');
var arcade_percent = document.getElementById('arcade_percent');
var fighting_percent = document.getElementById('fighting_percent');
var casino_percent = document.getElementById('casino_percent');
var defense_percent = document.getElementById('defense_percent');
var board_percent = document.getElementById('board_percent');
var sports_percent = document.getElementById('sports_percent');
var puzzle_percent = document.getElementById('puzzle_percent');
var multiplayer_percent = document.getElementById('multiplayer_percent');
var driving_percent = document.getElementById('driving_percent');
var shooter_percent = document.getElementById('shooter_percent');
var classic_percent = document.getElementById('classic_percent');
var gadget_percent = document.getElementById('gadget_percent');
var webcam_percent = document.getElementById('webcam_percent');

// Sum the inputs

var total_percent = action_percent + adventure_percent + animation_percent + arcade_percent + fighting_percent + casino_percent 	+ defense_percent + board_percent + sports_percent + puzzle_percent + multiplayer_percent + driving_percent + shooter_percent + classic_percent + gadget_percent + webcam_percent

if(total_percent != 100){

} 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.