Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 10th, 2005, 10:28 AM   #1
raikkonen
Newbie
 
Join Date: Jun 2005
Posts: 29
Rep Power: 0 raikkonen is on a distinguished road
a little help on basic JS programming

hi guys, need your help again.. cant figure out whats wrong with my codes.. need so expert help.. Plese help me on the codes below. my validation dont seems to work. althought it work well at first. and i also want to make it mark the text fields that it will add a score when the user gets the ans correct.
The Codes:

<HTML><HEAD><TITLE></TITLE>
<SCRIPT language=javascript>
<!--
function validation()
{

var mark="0";
var temp;

if (form1.name.value == "") {
alert("Please fill in appropriately");
return false;
}


if (form1.question.value = form1.answer1.value ) {
mark++;
}else{
return false;
}


/*
var theone;
if (document.form1.station[3].checked==true) {
mark+=1;
alert("Correct");
theone=i;
return false;
}

*/


form1.submit();


}

-->
</SCRIPT>

</HEAD>
<BODY>
<FORM name=form1 action=test2.html method=post>Question 1 Answer: <INPUT size=40
name=question> <INPUT onclick=validation() type=button value=Submit></TD>
<INPUT type=reset value=Reset></TD> <INPUT type=hidden value=9 name=answer1>
</FORM></BODY></HTML>

thanks guys... cheers
raikkonen is offline   Reply With Quote
Old Aug 10th, 2005, 10:35 AM   #2
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
please use CODE tags

if (form1.question.value == "") {
  alert("Please fill in appropriately");
  return false;
}

if (form1.question.value == form1.answer1.value ) {
  mark++;
}else{
  return false;
}
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Aug 11th, 2005, 2:14 AM   #3
raikkonen
Newbie
 
Join Date: Jun 2005
Posts: 29
Rep Power: 0 raikkonen is on a distinguished road
i did insert code tag in my file. i have amended e validating part, but i still dont know how to keep track of the score. pls advice. thanks
raikkonen is offline   Reply With Quote
Old Aug 11th, 2005, 9:54 AM   #4
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
HTTP is a stateless protocol, therefore you cannot simply carry values over from one page to another without using storage on the server or client. Without using server-side code, you are left to use cookies for storing and retrieving the mark information. So, you will create/set the cookie on page A and retrieve/update the cookie on page B, C, etc.

Google: JavaScript cookies - there are tons of examples out there

p.s. I meant use the CODE tags when you post here... so your source code will be more readable and copyable (see how my source code looks in my first reply).
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC