Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 01-26-2014, 05:01 AM   #1
BertrandThibaut
Junior Member
BertrandThibaut began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jan 2014
Device: none
Create a javascript quizz for Epub3 in Sigil

Hello, I'm trying to add a quizz form in javascript to an ebook created with Sigil (0.6.2).

Here is the code I used

Quote:
<head>
<title></title>
<link href="../Styles/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">




//<![CDATA[
function calcul()
{
nombreDeQuestion=10;
nom=new Array();
nomLength=new Array();
point=0;
for(n=0;n<=(nombreDeQuestion-1);n++)
{
nom[n]=document.getElementsByName("choix_rep_"+n);
nomLength[n]=nom[n].length;
for(q=0;q<=(nomLength[n]-1);q++)
{
if(nom[n][q].checked==true)
{point=point+eval(nom[n][q].value);}
else
{point=point;}

}
}
document.form_qz.txtNb.value=point;
}

//]]>
</script>
</head>


Quote:
<div>
<form id="form_qz">
<p>Le colvert est :<br />
<input type="radio" name="choix_rep_0" value="1" />un canard<br />
<input type="radio" name="choix_rep_0" value="0" />un coq<br />
<input type="radio" name="choix_rep_0" value="0" />un perroquet</p>

<p>Le petit-gris est:<br />
<input type="radio" name="choix_rep_1" value="0" />un rat<br />
<input type="radio" name="choix_rep_1" value="0" />un chat<br />
<input type="radio" name="choix_rep_1" value="1" />un escargot</p>

<p>Quel est le nom du poisson surnommé le "cheval de mer"?<br />
<input type="radio" name="choix_rep_2" value="0" />Le dauphin<br />
<input type="radio" name="choix_rep_2" value="1" />L'hippocampe<br />
<input type="radio" name="choix_rep_2" value="0" />L'espadon</p>

<p>Quelle est la capitale de l'Italie?<br />
<input type="radio" name="choix_rep_3" value="0" />Venise<br />
<input type="radio" name="choix_rep_3" value="0" />Milan<br />
<input type="radio" name="choix_rep_3" value="1" />Rome</p>

<p>Quelle est la capitale de l'Espagne?<br />
<input type="radio" name="choix_rep_4" value="1" />Madrid<br />
<input type="radio" name="choix_rep_4" value="0" />Tolède<br />
<input type="radio" name="choix_rep_4" value="0" />Barcelone</p>

<p>Quelle est la capitale de la Chine?<br />
<input type="radio" name="choix_rep_5" value="1" />Pékin<br />
<input type="radio" name="choix_rep_5" value="0" />Hongkong<br />
<input type="radio" name="choix_rep_5" value="0" />Shanghaï</p>

<p>Quelle pâtisserie mange-t-on le plus souvent à Noël en France?<br />
<input type="radio" name="choix_rep_6" value="0" />La galette des rois<br />
<input type="radio" name="choix_rep_6" value="1" />La bûche de Noël<br />
<input type="radio" name="choix_rep_6" value="0" />La religieuse</p>

<p>Est-ce que l’été est suivi immédiatement par le printemps?<br />
<input type="radio" name="choix_rep_7" value="1" />Non<br />
<input type="radio" name="choix_rep_7" value="0" />Oui</p>

<p>Est-ce que le sel a un goût sucré?<br />
<input type="radio" name="choix_rep_8" value="1" />Non<br />
<input type="radio" name="choix_rep_8" value="0" />Oui</p>

<p>Les pommes sont-elles toujours vertes?<br />
<input type="radio" name="choix_rep_9" value="0" />Oui<br />
<input type="radio" name="choix_rep_9" value="1" />Non</p>

<p>le nombre de réponses correctes est : <input type="button" name="btnAfficher" value="afficher le reslultat" onclick="calcul();" /><br />
<input type="text" name="txtNb" id="resultat" /></p>
</form>
</div>
The form is well displayed in my epub file but...

- When I choose an answer for the questions 1 or 2, clicking on the radio button send me to my cover page.
- I can choose an answer for question 3 to 10 but when I click on the button btnAfficher to get my results, nohtings happens.

I test my epub file with Firefox 26.0

Any ideas how to solve it ?
BertrandThibaut is offline   Reply With Quote
Old 01-26-2014, 06:46 AM   #2
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 9,539
Karma: 44002482
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Sigil is ePub2-only.
No scripting in ePub2.
DiapDealer is offline   Reply With Quote
 
Advertisement
Old 01-26-2014, 06:49 AM   #3
varlog
just member
varlog ought to be getting tired of karma fortunes by now.varlog ought to be getting tired of karma fortunes by now.varlog ought to be getting tired of karma fortunes by now.varlog ought to be getting tired of karma fortunes by now.varlog ought to be getting tired of karma fortunes by now.varlog ought to be getting tired of karma fortunes by now.varlog ought to be getting tired of karma fortunes by now.varlog ought to be getting tired of karma fortunes by now.varlog ought to be getting tired of karma fortunes by now.varlog ought to be getting tired of karma fortunes by now.varlog ought to be getting tired of karma fortunes by now.
 
varlog's Avatar
 
Posts: 147
Karma: 457016
Join Date: Sep 2012
Location: Europa
Device: prs t1
Not really Sigil question.
As far as I know EPUB2 doesn't support javaScript.
That said and not knowing javaScript:

document.getElementById('resultat').value=point;

seems to work in Sigil at least.
varlog is offline   Reply With Quote
Old 01-26-2014, 10:04 AM   #4
mrmikel
Color me gone
mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.
 
Posts: 2,086
Karma: 1444487
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
That is a very old version of Sigil, since it is up to 0.7.4. The later versions don't thrash epub3 code so much.

You might be better off using Calibre's standalone editor, which is not focused on any particular version of epub.

You will still have to test, as you are, in a browser, as neither Sigil nor calibre can test this sort of thing. Though if you are aimed for an Apple device, you really will need to test in an Apple device, since there is no reliable emulator even for all devices by a manufacturer.
mrmikel is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any android epub reader supporting epub3 with audio/video/javascript? happycoding Android Developer's Corner 10 07-29-2014 12:16 PM
An epub3 version of Sigil ? apulia03 Sigil 9 11-28-2012 02:07 AM
Does Sigil filter/strip out any epub3 code when saving? maestroc Sigil 9 10-25-2012 05:18 PM
JAVASCRIPT support in ePub2/ePub3 Raja1205 ePub 7 09-03-2012 07:48 AM
epub3 Sigil Poetry(fixed layout) Giggleton Sigil 7 04-04-2011 01:58 PM


All times are GMT -4. The time now is 02:32 AM.


MobileRead.com is a privately owned, operated and funded community.