Forum : What is the error?
Brief description  about Online courses   join in Online courses
View Sasmita  Patnaik 's Profile

What is the error?

function day(){
date = document.multistring.txt1.value;
var sup = "";
if (date == 1 || date == 21 || date ==31)
{
sup = "st";
}
else if (date == 2 || date == 22)
{
sup = "nd";
}
else if (date == 3 || date == 23)
{
sup = "rd";
}
else
{
sup = "th";
}
var month = document.multistring.txt2.value;
var year = document.multistring.txt3.value;

alert("Today is " date "<SUP>" sup "</SUP> " of month year);

}

<Input Type = Button VALUE = "Click here" onClick = "day();">
Asked by Sasmita Patnaik | Jul 30, 2010 |  Reply now
Replies (4)
View sasmita patnaik 's Profile
Ya its working. Had some minor mistakes. Thnx dear
Aug 1, 2010
View rashmi kumari 's Profile
It is working in my code.
It means you do something wrong in diff place.
you may check it in diff one.
Aug 1, 2010
View sasmita patnaik 's Profile
I have the same code both in my Head and body section, but its not working.
Aug 1, 2010
View rashmi kumari 's Profile
copy this code to your head section
<script>
function date() {
var date=document.frmone.txt1.value;
var month=document.frmone.txt2.value;
var year=document.frmone.txt3.value;
var sup ="";

if (date == '1'|| date == '21' || date =='31')
{
sup = 'st';
}
else if (date == '2' || date == '22')
{
sup = 'nd';
}
else if (date == '3' || date == '23')
{
sup = 'rd';
}
else
{
sup = 'th';
}
alert('Today is ' + date + sup +' ' + month + ' of '+ year );

}
</script>
and copy it to your body section U'll get the result.
<form Name=frmone>
Date:<input type=text NAME=txt1 SIZE=10 value=""/>
Month:<input type=text NAME=txt2 SIZE=10 value=""/>
Year:<input type=text NAME=txt3 SIZE=10 value=""/>
<input type=button NAME=b1 value="Complete Date" onClick="date();"/>
</form>

Hope this ll solve ur prb.
Jul 31, 2010