Hi all,
I have made to select box in which one is adult and other is for child .
adult select box have 1 to 10 numeric value and child have 1 to 10 numeric value.

but now i want to make if both of select box total is greater than 10 then it will give alert that Total adult and child can not be greater than 10 and it will return false.

I am trying to do it . But it is not happening . Actually i am not able to get value of adult or child in javascript code . How i can do this ??????//
Please help me .
Thanks
Gagan

Recommended Answers

All 2 Replies

Give us to see a piece of code, without it it's hard to say where can be the bug.
But: the value got from the select is by default supposed to be a string. In JavaScript the plus sign does not differ between the numeric addition and string concatenation hence "0"+"1" gives "01". To force the numeric conversion try someting like:
1*audult.value + 1*child.value

Jan

Give us to see a piece of code, without it it's hard to say where can be the bug.
But: the value got from the select is by default supposed to be a string. In JavaScript the plus sign does not differ between the numeric addition and string concatenation hence "0"+"1" gives "01". To force the numeric conversion try someting like:
1*audult.value + 1*child.value

Jan

thanks for reply ,
i have solved this problem. i was using this in javacript like this

a=(document.form1.adult.value);
	 b=(document.form1.child.value);
c=a+b;

but when i tried to this like this it has solved my problem :

a=parseInt(document.form1.adult.value);
	 b=parseInt(document.form1.child.value);

SO i have solved this . Thanks
gagan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.