Discussion Forums  >  WebViews and HTML for Mobile

Replies: 11    Views: 79

JustinPadgett
Android Fan
Profile
Posts: 13
Reg: Jun 03, 2012
winston salem n...
1,680
06/04/12 10:03 AM (13 years ago)

HTML form submit not calling JS functions

Hello everyone, I'm creating an App that uses the html5 plugin. This app is a simple 10 question quiz that (on submit) displays one of two possible html pages (pass or fail.html) The quiz loads like it is supposed to, but when you click finish, nothing happens. I have the html files (pass, fail.html) in the Manage Screens and Actions section, and I have also tested the code in my web browser(working). Can anyone guide me in the right direction? If you need sample code I will be more than happy to paste a snippet. Thanks
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/04/12 10:20 AM (13 years ago)
Please paste.
 
JustinPadgett
Android Fan
Profile
Posts: 13
Reg: Jun 03, 2012
winston salem n...
1,680
like
06/04/12 10:50 AM (13 years ago)
"Take the Quiz" html5 : <p> <title></title> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> <meta content="width=device-width; initial-scale=1.0; maximum-scale=2.0; user-scalable=1;" name="viewport" /> <!-- begin quiz script --><script type="text/javascript"> function finish() { var ext = '.html'; var results = new Array("none","pass","fail"); var nums = new Array(3); for(var i = 0; i < nums.length; i++) nums[i] = 0; for(var i = 1; i <= 10; i++) { var q = document.forms['quiz'].elements['question_'+i]; if(q[0].type=='checkbox') { var n = 0; } for(var j = 0; j < q.length; j++) { if(q[j].checked) { var a = q[j].value.split(','); for(var k = 0; k < a.length; k++) { nums[a[k]]++; } if(q[j].type=='radio') break; else n++; } if(j == q.length-1&&q[j].type=='radio') {nums[0]++;} } if(q[0].type=='checkbox'&&((document.forms['quiz'].elements['question_'+i+'_min']&&n<document.forms['quiz'].elements['question_'+i+'_min'].value)||(document.forms['quiz'].elements['question_'+i+'_max']&&n>document.forms['quiz'].elements['question_'+i+'_max'].value))) nums[0]++; } var j = new Array('0'); for (i in nums) if(nums[i]>nums[j[0]]){j=new Array(''+i);} else if(nums[i]==nums[j[0]])j[j.length] = i; //var o = '';for(var i in results)o+=results[i]+'='+nums[i]+'\n'; //alert(o); if(nums[0]!=0) { alert('You missed or incorrectly answered '+nums[0]+' questions!'); } else if(j[0]==0) { alert('No result could be determined.'); } else { location = results[j[0]]+ext; } } </script><!-- end quiz script --><style type="text/css"> html{background-color:transparent;height:100%;width:100%;} body{background-color:transparent;font-size:11pt;font-family:helvetica;} img{border:0px;} </style> <!-- begin quiz html --></p> <p> <img src="quiz.png" /></p> <hr /> <p> </p> <form action="javascript:finish();" name="quiz" onsubmit="finish()"> <fieldset style="width:300px;"> <legend><strong>What color is the sky? (During the day)</strong> </legend> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_1" type="radio" value="1" /> Blue</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_1" type="radio" value="2" /> Royal Sky Blue</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_1" type="radio" value="2" /> White</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_1" type="radio" value="2" /> I'm color blind, sorry about that</font></fieldset> <br /> <br /> <fieldset style="width:300px;"> <legend><strong>10 +10 = ?</strong> </legend> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_2" type="radio" value="2" /> 9</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_2" type="radio" value="2" /> 11</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_2" type="radio" value="2" /> -10</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_2" type="radio" value="1" /> 20</font></fieldset> <br /> <br /> <fieldset style="width:300px;"> <legend><strong>Collectively, Pavarotti, Domingo, and Carreras are better known as what singing trio? </strong> </legend> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_3" type="radio" value="2" /> The Three Amigos</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_3" type="radio" value="2" /> The Three Baritones</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_3" type="radio" value="1" /> The Three Tenors </font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_3" type="radio" value="2" /> The Divas</font></fieldset> <br /> <br /> <fieldset style="width:300px;"> <legend><strong>In the Hans Christian Andersen story, what tiny item did the Princess feel through a stack of mattresses? </strong> </legend> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_4" type="radio" value="1" /> Pea</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_4" type="radio" value="2" /> Bean</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_4" type="radio" value="2" /> Needle</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_4" type="radio" value="2" /> Matchstick</font></fieldset> <br /> <br /> <fieldset style="width:300px;"> <legend><strong>From 1990 until they went to the Euro, the Deutsche Mark was the official currency of what country? </strong> </legend> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_5" type="radio" value="2" /> France</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_5" type="radio" value="2" /> Denmark</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_5" type="radio" value="2" /> Netherlands</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_5" type="radio" value="1" /> Germany</font></fieldset> <br /> <br /> <fieldset style="width:300px;"> <legend><strong>In Bill Waterson's popular comic strip, what is the name of Calvin's stuffed tiger? </strong> </legend> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_6" type="radio" value="1" /> Hobbes</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_6" type="radio" value="2" /> Locke</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_6" type="radio" value="2" /> Tigger</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_6" type="radio" value="2" /> Tony</font></fieldset> <br /> <br /> <fieldset style="width:300px;"> <legend><strong>What chairman of Microsoft allegedly receives about 4 million e-mails a day? </strong> </legend> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_7" type="radio" value="2" /> Steve Jobs</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_7" type="radio" value="1" /> Bill Gates</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_7" type="radio" value="2" /> Larry Ellison</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_7" type="radio" value="2" /> Barry Diller</font></fieldset> <br /> <br /> <fieldset style="width:300px;"> <legend><strong>Reportedly, Bill Clinton used what poet's "Leaves of Grass" to woo both Hillary and Monica? </strong> </legend> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_8" type="radio" value="2" /> T.S. Eliot</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_8" type="radio" value="2" /> Emily Dickinson</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_8" type="radio" value="1" /> Walt Whitman</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_8" type="radio" value="2" /> Pablo Neruda</font></fieldset> <br /> <br /> <fieldset style="width:300px;"> <legend><strong>What classic comedy film popularized the line "Joey, do you like movies about gladiators?"</strong> </legend> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_9" type="radio" value="1" /> Airplane!</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_9" type="radio" value="2" /> Duck Soup</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_9" type="radio" value="2" /> Caddyshack</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_9" type="radio" value="2" /> There's Something About Mary</font></fieldset> <br /> <br /> <fieldset style="width:300px;"> <legend><strong>In 1912, the crew of the Carpathia helped assist the survivors of what nautical disaster? </strong> </legend> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_10" type="radio" value="2" /> Andrea Doria</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_10" type="radio" value="2" /> Lusitania</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_10" type="radio" value="2" /> Edmond Fitzgerald</font><br /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input name="question_10" type="radio" value="1" /> Titanic</font></fieldset> <br /> <br /> <input name="Finish" type="submit" value="Finish" /> <input type="reset" value="Reset" /></form> <p> </p> <form name="quiz"> </form> <!-- end quiz html --><p> </p>
 
JustinPadgett
Android Fan
Profile
Posts: 13
Reg: Jun 03, 2012
winston salem n...
1,680
like
06/04/12 10:51 AM (13 years ago)
fail.html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 1</title> </head> <body> <h1>You have failed!</h1> <img src="http://www.buzztouch.com/applications042612/JA456B1DDF25D7852B2F204F3/images/fail.jpg" /> <p>Contact JCwebb for your development solutions! <a href="http://www.jcwebb.com" target="_blank">JCWebb</a></p> </body> </html>
 
JustinPadgett
Android Fan
Profile
Posts: 13
Reg: Jun 03, 2012
winston salem n...
1,680
like
06/04/12 10:51 AM (13 years ago)
pass.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 1</title> </head> <body> <h1> You have passed the test</h1> <img src="http://www.buzztouch.com/applications042612/JA456B1DDF25D7852B2F204F3/images/pass.jpg"/> <p>Contact JCwebb for your development solutions! <a href="http://www.jcwebb.com" target="_blank">JCWebb</a></p> </body> </html>
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/04/12 11:55 AM (13 years ago)
on submit) displays one of two possible html pages (pass or fail.html) It would be best to have the on submit to go to a new div instead of going to a decorate html. The quiz loads like it is supposed to, but when you click finish, nothing happens. I have the html files (pass, fail.html) in the Manage Screens and Actions section, The code fails to take into account that your web air is different from calling a file in the assets directory. and I have also tested the code in my web browser(working). Can anyone guide me in the right direction? Try: A. Multi-page html doc. Or B. http:/// Fred
 
JustinPadgett
Android Fan
Profile
Posts: 13
Reg: Jun 03, 2012
winston salem n...
1,680
like
06/04/12 12:48 PM (13 years ago)
What is multipage html doc?
 
JustinPadgett
Android Fan
Profile
Posts: 13
Reg: Jun 03, 2012
winston salem n...
1,680
like
06/04/12 12:55 PM (13 years ago)
What is multipage html doc?
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/04/12 01:32 PM (13 years ago)
Google jQuery mobile. Fred
 
JustinPadgett
Android Fan
Profile
Posts: 13
Reg: Jun 03, 2012
winston salem n...
1,680
like
06/04/12 02:01 PM (13 years ago)
What is multipage html doc?
 
JustinPadgett
Android Fan
Profile
Posts: 13
Reg: Jun 03, 2012
winston salem n...
1,680
like
06/04/12 02:02 PM (13 years ago)
ok thanks, sry for the multiple posts, must be a bug :/
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/04/12 02:04 PM (13 years ago)
Not a bug, it's the back button. It's a hard habit to break. Fred Perhaps flaw, but not a bug.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.