/    Sign up×
Community /Pin to ProfileBookmark

Help displaying results of user input in a form to display in a popup

hi guys please go to : [URL=http://www.satellitecitytv.net/compound_interest.html]http://www.satellitecitytv.net/compound_interest.html[/URL]

I need a popup window to display everything after the ‘Calculate’ Button is clicked. Anybody able to help me out?

I Also need a way of validating the user input in the form to make it more robust so they cannot type characters other than numbers into each individual box, if they do a popup window appears.

Anyone?!?!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@BalkeshwarNov 25.2006 — hi

according your first question. you can do it by using parent/child window concept.

you can open a child window and can easily transfer all value of parent form to the child form like this try to test this code

function _emailthis()

{

ChildWin=window.open("TyperMail.aspx", "ChildWin", "scrollbars,innerwidth=600,innerheight=600");

window.setTimeout("timer()",1000);


}

function timer()

{

ChildWin.document.forms[0].txtbody.value=document.getElementById('hindi_text').value;

}

timer function is used because it wait until all controls have loaded in child form

and second question

u can easily validate user by using javasrcipt functions or validation controls.
Copy linkTweet thisAlerts:
@jonthomas83authorNov 25.2006 — thing is, I don't really know where to place that code into my existing code in order to make my results show in that new popup window.

As for validation, I know I should use javascript functions or validation controls, but the one's I've tried don't work like they should:

[CODE]var princ;
var ratepc;
var years;
var rate;
var power;
var math1 = new Array();
function calcAmt(frm) {
princ = eval(frm.pr.value);
ratepc = eval(frm.rt.value);
years = eval(frm.yr.value);
rate = ratepc / 100;
power = Math.pow((1 + rate), years);
frm.amt.value = Math.round(princ * power * 100) / 100;
math1[0] = Math.round(princ * power * 100) / 100;
math1[1] = Math.round((frm.amt.value - princ) * 100) / 100;
frm.inter.value = Math.round((frm.amt.value - princ) * 100) / 100;
}
function checkInput(frm) {
if (rate == 0 || rate > .3) {
window.alert ("Are you sure that the interest rate is " + ratepc +"%?");
frm.rt.focus();
}
if (years == 0 || years > 30) {
window.alert ("Are you sure that the term is " + years + " years?");
frm.yr.focus();
}
if (isNaN(princ)){
window.alert("You have entered an incorrect value in the 'Principal' box")
frm.pr.focus();
}
if (isNaN(rate)){
window.alert("You have entered an incorrect value in the 'Rate' box")
frm.rt.focus();
}
if (isNaN(years)){
window.alert("You have entered an incorrect value 'Years' box")
frm.yr.focus();
}
}[/CODE]


This works to a certain extent but if you view the page and try it out: [URL]http://www.satellitecitytv.net/compound_interest.html[/URL] - you'll find that all three popup boxes come up if only one box is invalid and the others are fine. How do I fix that, would be a better question I think!

Many thanks for your help!

Jonathan
×

Success!

Help @jonthomas83 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...