dude, your code is pretty wonky, try this out to make a quiz http://www.cj-design.com/products/free_downloads/javascript/cjmultiplechoicequiz[^] your time calculation will never work since it is declared at the end of the function. cullentElt is "current Element" you are navigating to all the controls in your form and cheking one by one if they are checked or nor, if they are they shall be matched with the correct answer. i would rather suggest you to use event, for change in option, calculate the score at that time itself, it will make your code hardly 5-10 line. read about "events" in javascript.
Parinay Bansal
Posts
-
JavaScript: Need help understanding what's happening in this loop. -
javscipt: hex to string conversion problem:hello, I am trying to develop a project using smart card. I am using SCardX_easy activex control in my webpage to extract info from my smart card. what i recieve in DataBuffer is a string of hex values separated by a white space and without a leading zero. for example ReceivedDataBuffer = "5B 50 0A 3E 5C 77 D8" and so on. now i need to convert this to a meaningful string say "test" how do i do that. this is what i am currently doing: ------------------------------------------ var data = new Array(); data = ReceivedDataBuffer.split("0A"); for (i=0; i<data.length;> { AddSubLine(data[i]); } -------------------------------------------- but instead of the data[i] containing hex i need string. "0A" is the newline character in hex i intend to separate data using newline as data length is variable in nature which is being stored in the card. thanks also any suggestions regarding my approach would be appreciated as i am basically a c programmer and have been taked javascript. i have gone through the basics but am stuck
-
howto insert ip address into mysql databasei am doing $sth = $dbh->prepare("insert into loginout values ($ref->{'CARD_ID'}, '$name' , now(), NULL"); but keep getting the following error. DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at ./iothread.pl line 92, line 1. Client 10.168.1.2:3720 says: 11111::1100::login please help me
-
getting error "Use of uninitialized value in concatenation (.) or string" what this?hi i am getting error as: Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, line 1. during runtime and the output looks like this: Multiplex server running on port 4444... Created thread 1 for new client 10.168.1.2:3233 Use of uninitialized value $_ in scalar chomp at ./iothread.pl line 66, line 1. 1005874632400418 1234 login Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, line 1. 10895 Thread 1 terminated abnormally: Not a CODE reference at ./iothread.pl line 87, line 1.
#!/usr/bin/perl
iothreadserv.pl
use warnings;
use strict;
use integer;BEGIN
{
use Config;
die "No thread support!\n" unless $Config{'usethreads'};
}use Thread;
use IO::Socket;
use DBI;
use DBD::mysql;Autoflushing on
$| = 1;
my $port = 4444;
my $server = IO::Socket->new(
Domain => PF_INET,
Proto => 'tcp',
LocalPort => $port,
Listen => SOMAXCONN,
Reuse => 1,
);die "Bind failed: $!\n" unless $server;
print "Multiplex server running on port $port...\n";while (my $connection = $server->accept)
{
my $name = $connection->peerhost;
my $port = $connection->peerport;
my $thread = new Thread(\&connection, $connection, $name, $port);
print "Created thread ",$thread->tid," for new client $name:$port\n";
$thread->detach;
}
exit;child thread - handle connection
sub connection
{
my ($connection, $name, $port) = @_;
$connection->autoflush(1);
#############################my sql connect###############################
my $platform = "mysql";
my $database = "project";
#my $host = "localhost";
#my $port = "3306";
my $user = "root";
my $pw = "";# DATA SOURCE NAME my $dsn = "dbi:mysql:$database"; # PERL DBI CONNECT my $dbh = DBI->connect($dsn, $user, $pw) or die "cannot connect to database"; #######################################################################33 print $connection "You're connected to the server!\\n"; my $client = <$connection>; chomp; # ($client); #while (<$connection>) { if ($client =~ /::login/) { print $connection "Login Initiated\\n"; my $rand = int(rand(100000)); print $connection "Your rand number : $rand"; #$client =~ s/(\[\\$\\@\\\\\])/\\\\$1/mg; ##escape all $, @ and \\ #$client = quotemeta $client; my @recv\_string = split /::/ , $client; foreach (@recv\_string) { print "$\_ \\n"; } #next line inje
-
Helpwell i was a noob too sometime ago take this link and it surely will help http://rapidshare.com/files/4333859/\_Book\_\_Perl\_\_Wrox\_\_PDF\_\_Professional\_Perl\_Programming.pdf i consider it my bible.. best of luck i am doing a similar project working with perl and mySQL
-
assertion faliurethank you gentlemen i was missing out on the part "extern SCard SCManager" replaced with "extern SCard *SCManager" such a fool i have been yes sir thank you for your advice, i really must go back to my c++ basics. It appears that i have missed out on very basic and important lessons which i sould have taken before starting to develop a full fledged application i will surely do that from now on. but yes thanks to you, now my code runs with no error. i will not forget to get back with any other problems i face in the future.
-
assertion faliureoops sorry didnt see that coming sorry for the lame reply well now i tried id again but with more number of errors. the previous two remain when i have changed all refrences from SCManager.function() to SCManager->function() new error says that scard does not have an overloaded operator -> ??? what exactly to interpret from this? in my dialog class i define variable as extern SCard SCmanager how to deal with that? sorry for the silly questions wont repeat that..
-
assertion faliurethanks for your interest but now the code wont compile with 2 errors. error 1: error C2040: 'SCManager' : 'class SCard *' differs in levels of indirection from 'class SCard' AT SCard *SCManager; error 2: error C2582: 'SCard' : 'operator =' function is unavailable AT SCManager = new SCard; ----------------------------------------------------------------------------------- for the 2nd error my opinion is that i will need to override 'operator =' as we do in turbo c++. i also do have an initial guess the inline assert says someting about application name _AFXWIN_INLINE LPCTSTR AFXAPI AfxGetAppName() { ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; } my idea is if i somehow set afxCurrentAppName to NULL wont it rule out??
-
assertion faliureI am creating an application which will read data from a smart card and send it across to a server on the network it is an MFC dialog based application i am a starter with VC++ whenever i compile my application it shows me error: Assertion failure in afxwin1.inl at line 27 the code at line 27 is: { ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; } if i ignore it my application runs fine but this error is not fine. i am using VC++ 6.0 it comes if i add SCard SCManager; to be a global variable in my app SCard definition is: class SCard : public CWnd { public: SCard(); public: LONG GetDataString(CString &DataStream, DWORD &dwRecvLength); CString GetErrorMessage(LONG lReturn); LONG m_SCardConnect(); void m_SCardSelectReader(); LONG m_SCardReleaseConext(); LONG m_SCardEstablishContext(); CString m_SCardListReaders(); CString m_SelectedReader; // the selected reader SCARDHANDLE m_hCardHandle; // handle to the card SCARDCONTEXT m_hSC; //context handle to the card virtual ~SCard(); protected: CString m_csReaderList; //list of available readers. DECLARE_MESSAGE_MAP() }; please help me