Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-26-2007, 05:49 PM   PM User | #1
yuro
New to the CF scene

 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
yuro is an unknown quantity at this point
Numeric answer lower than previous answer

I am trying to create a table where the numeric answer for column B must be lower than the numeric answer for column A. I am stuck and can't get any code to work. Any suggestions?
yuro is offline   Reply With Quote
Old 02-26-2007, 06:46 PM   PM User | #2
Rappa
Regular Coder

 
Rappa's Avatar
 
Join Date: Nov 2005
Location: LI
Posts: 356
Thanks: 21
Thanked 9 Times in 9 Posts
Rappa is an unknown quantity at this point
Thats way too brief, have you got any code to post? or a more specific question about what you want?
Rappa is offline   Reply With Quote
Old 02-27-2007, 04:06 PM   PM User | #3
yuro
New to the CF scene

 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
yuro is an unknown quantity at this point
that is the problem. i am trying to create a code out of nothing. right now i have the table programmed, but need to somehow create the forcing of column B to be lower than column A. For example field Q13_A_1 has to be greater than or equal to field Q13_B_1. The logic for the table has to be created below this part of the table logic (this logic is just forcing all fields to be answered and to be answered with a whole number).

ANY IDEAS????

THANKS


PdcNextPage();

return true;
}
function PdcValidateQuestions(){
if(document.PdcSurvey.Q13_A_1.value == '') {
PdcJumpToQuestion('#Q13_A_1', 'Please tell about your CDs.');
return false;
}
if(document.PdcSurvey.Q13_A_2.value == '') {
PdcJumpToQuestion('#Q13_A_2', 'Please tell about your Digital albums.');
return false;
}
if(document.PdcSurvey.Q13_A_3.value == '') {
PdcJumpToQuestion('#Q13_A_3', 'Please tell about your Digital tracks.');
return false;
}
var textValue = document.PdcSurvey.Q13_A_1.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1))) {
PdcJumpToQuestion('#Q13_A_1', 'Your answer to CDs must be a whole number.');
return false;
}
var textValue = document.PdcSurvey.Q13_A_2.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1))) {
PdcJumpToQuestion('#Q13_A_2', 'Your answer to Digital albums must be a whole number.');
return false;
}
var textValue = document.PdcSurvey.Q13_A_3.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1))) {
PdcJumpToQuestion('#Q13_A_3', 'Your answer to Digital tracks must be a whole number.');
return false;
}
if(document.PdcSurvey.Q13_B_1.value == '') {
PdcJumpToQuestion('#Q13_B_1', 'Please tell about your CDs.');
return false;
}
if(document.PdcSurvey.Q13_B_2.value == '') {
PdcJumpToQuestion('#Q13_B_2', 'Please tell about your Digital albums.');
return false;
}
if(document.PdcSurvey.Q13_B_3.value == '') {
PdcJumpToQuestion('#Q13_B_3', 'Please tell about your Digital tracks.');
return false;
}
var textValue = document.PdcSurvey.Q13_B_1.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1))) {
PdcJumpToQuestion('#Q13_B_1', 'Your answer to CDs must be a whole number.');
return false;
}
var textValue = document.PdcSurvey.Q13_B_2.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1))) {
PdcJumpToQuestion('#Q13_B_2', 'Your answer to Digital albums must be a whole number.');
return false;
}
var textValue = document.PdcSurvey.Q13_B_3.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1))) {
PdcJumpToQuestion('#Q13_B_3', 'Your answer to Digital tracks must be a whole number.');
return false;
}
return true;
yuro is offline   Reply With Quote
Old 02-27-2007, 07:09 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,103
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Like this:

var textValue = document.PdcSurvey.Q13_B_3.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1)) || (textValue >= Q13_A_3.value)) {
PdcJumpToQuestion('#Q13_B_3', 'Your answer to Digital tracks must be a whole number more than the answer to Q13_A_3.');
return false;
}
Philip M is offline   Reply With Quote
Old 02-28-2007, 02:09 PM   PM User | #5
yuro
New to the CF scene

 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
yuro is an unknown quantity at this point
Thanks for the answer Phillip M.!

I am still having trouble with the code. It isnt performing the command. My new table logic reads below (I inserted the logic as a double check for the first column, only after it didnt work for the second column only). What am I missing? Thanks again!



}
function PdcValidateQuestions(){
if(document.PdcSurvey.Q13_A_1.value == '') {
PdcJumpToQuestion('#Q13_A_1', 'Please tell about your CDs.');
return false;
}
if(document.PdcSurvey.Q13_A_2.value == '') {
PdcJumpToQuestion('#Q13_A_2', 'Please tell about your digital albums.');
return false;
}
if(document.PdcSurvey.Q13_A_3.value == '') {
PdcJumpToQuestion('#Q13_A_3', 'Please tell about your digital tracks.');
return false;
}
var textValue = document.PdcSurvey.Q13_A_1.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1)) || (textValue >= Q13_B_1.value)) {
PdcJumpToQuestion('#Q13_A_1', 'Your answer must be a whole number, more than the answer to CDs aquired in past three months.');
return false;
}
var textValue = document.PdcSurvey.Q13_A_2.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1)) || (textValue >= Q13_B_2.value)) {
PdcJumpToQuestion('#Q13_A_2', 'Your answer must be a whole number, more than the answer to digital albums aquired in past three months.');
return false;
}
var textValue = document.PdcSurvey.Q13_A_3.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1)) || (textValue >= Q13_B_3.value)) {
PdcJumpToQuestion('#Q13_A_3', 'Your answer must be a whole number, more than the answer to digital tracks aquired in past three months.');
return false;
}
if(document.PdcSurvey.Q13_B_1.value == '') {
PdcJumpToQuestion('#Q13_B_1', 'Please tell about your CDs.');
return false;
}
if(document.PdcSurvey.Q13_B_2.value == '') {
PdcJumpToQuestion('#Q13_B_2', 'Please tell about your Digital albums.');
return false;
}
if(document.PdcSurvey.Q13_B_3.value == '') {
PdcJumpToQuestion('#Q13_B_3', 'Please tell about your Digital tracks.');
return false;
}
var textValue = document.PdcSurvey.Q13_B_1.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1)) || (textValue <= Q13_A_1.value)) {
PdcJumpToQuestion('#Q13_B_1', 'Your answer must be a whole number, less than the answer to CDs aquired in past year.');
return false;
}
var textValue = document.PdcSurvey.Q13_B_2.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1)) || (textValue <= Q13_A_2.value)) {
PdcJumpToQuestion('#Q13_B_2', 'Your answer must be a whole number, less than the answer to digital albums aquired in past year.');
return false;
}
var textValue = document.PdcSurvey.Q13_B_3.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1)) || (textValue <= Q13_A_3.value)) {
PdcJumpToQuestion('#Q13_B_3', 'Your answer must be a whole number, less than the answer to digital tracks aquired in past year.');
return false;
yuro is offline   Reply With Quote
Old 03-02-2007, 06:14 PM   PM User | #6
yuro
New to the CF scene

 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
yuro is an unknown quantity at this point
Just in case anyone reads this and has the same issue - I got the code to work by creating the following HTML
}
var textValue = document.PdcSurvey.Q13_B_1.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1)) || (textValue > document.PdcSurvey.Q13_A_1.value)) {
PdcJumpToQuestion('#Q13_B_1', 'Your answer must be a whole number. The number of CDs aquired in the past 3 months must be less than the number you own.');
return false;
}
var textValue = document.PdcSurvey.Q13_B_2.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1)) || (textValue > document.PdcSurvey.Q13_A_2.value)) {
PdcJumpToQuestion('#Q13_B_2', 'Your answer must be a whole number. The number of digital albums aquired in the past 3 months must be less than the number you own.');
return false;
}
var textValue = document.PdcSurvey.Q13_B_3.value;
if((textValue != '') && ((isNaN(parseInt(textValue)) || textValue.search(/\./) > -1)) || (textValue > document.PdcSurvey.Q13_A_3.value)) {
PdcJumpToQuestion('#Q13_B_3', 'Your answer must be a whole number. The number of digital tracks aquired in the past 3 months must be less than the number you own.');
return false;
}
yuro is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:26 AM.


Advertisement
Log in to turn off these ads.