Welcome, Guest
Username: Password: Remember me

TOPIC: Automatic calculation on the same page

Automatic calculation on the same page 3 years 3 months ago #63014

  • alex2610
  • alex2610's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
LimeSurvey Version 1.91+

Hi,

I need to have an automatic calculation within my questionnaire. So if one enters a number in one field, the result of an automatic calculation is presented in another field. I have a Script which does this for individual questions, but it does not work if there is more than one question on one page. I am a complete newbie, so sorry every step needs to be explained with a lot of detail.
I very much appreciate your help!
This is the code I have so far:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<link rel="stylesheet" type="text/css" media="all" href="www.brell.de/survey/scripts/jquery/css/start/jquery-ui.css" />
<link rel="stylesheet" type="text/css" media="all" href="www.brell.de/survey/scripts/jquery/css/start/lime-progress.css" />
<script type="text/javascript" src="www.brell.de/survey/scripts/jquery/jquery.js"></script>
<script type="text/javascript" src="www.brell.de/survey/scripts/jquery/jquery-ui.js"></script>
<link href="www.brell.de/survey/scripts/jquery/css/start/jquery-ui.css" media="all" type="text/css" rel="stylesheet" /><link href="www.brell.de/survey/scripts/jquery/css/start/lime-progress.css" media="all" type="text/css" rel="stylesheet" /><script type="text/javascript" src="www.brell.de/survey/scripts/jquery/jquery-ui.js"></script>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

<title>Messung der Zahlungsbereitschaft für produktbegleitende Dienstleistungen</title>

<meta name="generator" content="LimeSurvey www.limesurvey.org" />

<!-- The following line includes template.css and if an RTL-language is used template-rtl.css -->

<link rel='stylesheet' type='text/css' href='www.brell.de/survey/templates/default/template.css' />




<!--[if lte IE 6]>

<link rel="stylesheet" type="text/css" href="www.brell.de/survey/templates/default/ie_fix_6.css" />

<![endif]-->

<!--[if IE 7]>

<link rel="stylesheet" type="text/css" href="www.brell.de/survey/templates/default/ie_fix_7.css" />

<![endif]-->

<!--[if IE 8]>

<link rel="stylesheet" type="text/css" href="www.brell.de/survey/templates/default/ie_fix_8.css" />

<![endif]-->



<!-- The following CSS hides visual elements of the progress bar from screen readers. -->

<style type="text/css" media="aural tty">

progress-graph .zero, progress-graph .graph, progress-graph .cent { display: none; }

</style>



<script type="text/javascript" src="www.brell.de/survey/templates/default/template.js"></script>

<link rel="shortcut icon" href="www.brell.de/survey/templates/default/favicon.ico" />

<script type="text/javascript" src="www.brell.de/survey/scripts/survey_runtime.js"></script>
</head>

<body class="default lang-de groupbygroup">

<div class="outerframe">

<table class="innerframe">

<tr>

<td>

<form method='post' action='/survey/admin/admin.php' id='limesurvey' name='limesurvey' autocomplete='off'>
<!-- INPUT NAMES -->
<input type='hidden' name='fieldnames' value='33946X6X44SQ001_SQ001|33946X6X44SQ001_SQ002|33946X6X44SQ002_SQ001|33946X6X44SQ002_SQ002|33946X6X49SQ001_SQ001|33946X6X49SQ001_SQ002|33946X6X49SQ002_SQ001|33946X6X49SQ002_SQ002|33946X6X49SQ003_SQ001|33946X6X49SQ003_SQ002|33946X6X55SQ001_SQ001|33946X6X55SQ001_SQ002|33946X6X55SQ002_SQ001|33946X6X55SQ002_SQ002|33946X6X60SQ001_SQ001|33946X6X60SQ001_SQ002|33946X6X60SQ002_SQ001|33946X6X60SQ002_SQ002|33946X6X65SQ001_SQ001|33946X6X65SQ001_SQ002|33946X6X65SQ002_SQ001|33946X6X65SQ002_SQ002' id='fieldnames' />
<script type='text/javascript'>
<!--
// register the standard (last) onsubmit handler *first*
document.limesurvey.onsubmit = std_onsubmit_handler;
-->
</script><table class="survey-header-table">

<tr>
<td class="survey-description">
<h2>Messung der Zahlungsbereitschaft für produktbegleitende Dienstleistungen</h2><br />
<p></p>

</td>
</tr>
<tr>
<td class="graph">

<script type="text/javascript">
$(function() {
$("#progressbar").progressbar({
value: 150
});
});
</script>

<div id="progress-wrapper">
<span class="hide">Sie haben 150% dieser Umfrage fertiggestellt.</span>
<div id="progress-pre">0%</div>
<div id="progressbar"></div>
<div id="progress-post">100%</div>
</div>
</td>
</tr>
<tr>
<td class="language-changer">


</td>
</tr>
</table>
<input type='text' id='runonce' value='0' style='display: none;'/>
<!--JavaScript FOR CONDITIONAL QUESTIONS -->
<script type='text/javascript'>
<!--
function noop_checkconditions(value, name, type)
{
}

function checkconditions(value, name, type)
{
if (type == 'radio' || type == 'select-one')
{
var hiddenformname='java'+name;
document.getElementById(hiddenformname).value=value;
}

if (type == 'checkbox')
{
var hiddenformname='java'+name;
var chkname='answer'+name;
if (document.getElementById(chkname).checked)
{
document.getElementById(hiddenformname).value='Y';
} else
{
document.getElementById(hiddenformname).value='';
}
}
if (document.getElementById('runonce').value == '0')
{

if (((1)))
{
document.getElementById('question44').style.display='';
document.getElementById('display44').value='on';
}
else
{
document.getElementById('question44').style.display='none';
document.getElementById('display44').value='';
}
}
if (document.getElementById('runonce').value == '0')
{

if (((1)))
{
document.getElementById('question49').style.display='';
document.getElementById('display49').value='on';
}
else
{
document.getElementById('question49').style.display='none';
document.getElementById('display49').value='';
}
}
if (document.getElementById('runonce').value == '0')
{

if (((1)))
{
document.getElementById('question55').style.display='';
document.getElementById('display55').value='on';
}
else
{
document.getElementById('question55').style.display='none';
document.getElementById('display55').value='';
}
}
if (document.getElementById('runonce').value == '0')
{

if (((1)))
{
document.getElementById('question60').style.display='';
document.getElementById('display60').value='on';
}
else
{
document.getElementById('question60').style.display='none';
document.getElementById('display60').value='';
}
}
if (document.getElementById('runonce').value == '0')
{

if (((1)))
{
document.getElementById('question65').style.display='';
document.getElementById('display65').value='on';
}
else
{
document.getElementById('question65').style.display='none';
document.getElementById('display65').value='';
}
}

document.getElementById('runonce').value=1;
}
//-->
</script>



<!-- START THE GROUP -->
<table class="group">
<tr>
<td align="center">
<span class="group-name">Kompositionelle ZB-Erfassung</span>


<br />

<span class="group-description"><p>

Im Folgenden können Sie verschiedene Dienstleistungen, die von Ihnen als relevant eingestuft wurden, einzeln zu der Küche der Marke XXX dazukaufen.</p>

<p>

Geben Site bitte jeweils an, welchen prozentualen Aufschlag auf den Kaufpreis der Küche Sie für die jeweilige Ausprägung der betrachteten produktbegleitenden Dienstleistungen maximal akzeptieren würden.</p>

<p>

Betrachten Sie dabei separat jede Dienstleistungen und deren Ausprägungen in Kombination mit der Küche.</p>

<p>

</p>

<p>

Beispiele für Eingabemöglichkeiten: </p>

<p>

+3,5 "Für die Zugabe der entsprechenden Dienstleistung mit dieser Auspärgung würde ich einen Aufschlag auf den Küchenpreis in Höhe von maximal 3,5% akzeptieren." </p>

<p>

0 "Für diese Dienstleistungsausprägung / nicht vorhandene Dienstleistung würde ich keinen Aufschlag auf den Küchenpreis akzeptieren" </p>

</span>

<br /><br />




<!-- PRESENT THE QUESTIONS -->
<div id="question44" style="display: none;" class="array-multi-flexi-text mandatory">

<table class="question-wrapper">

<tr>

<td class="questiontext">

<span class="asterisk">*</span><span class="qnumcode"> </span>Lieferservice <script type="text/javascript" charset="utf-8">





<!--

function Custom_On_Load(){

var preis1=1100;

var ergebnis11=0;

var ergebnis12=0;





$('#answer33946X6X44SQ001_SQ001').change(function() {

if ( $('#answer33946X6X44SQ001_SQ001').val() > 0 ) {



ergebnis11=preis1*0.01*$('#answer33946X6X44SQ001_SQ001').val();

document.getElementById("answer33946X6X44SQ001_SQ002").style.width='150px';



$('#answer33946X6X44SQ001_SQ002').val(' = ' + ergebnis11 + ' EUR');



}





});





$('#answer33946X6X44SQ002_SQ001').change(function() {

if ( $('#answer33946X6X44SQ002_SQ001').val() > 0 ) {



ergebnis12=preis1*0.01*$('#answer33946X6X44SQ002_SQ001').val();

document.getElementById("answer33946X6X44SQ002_SQ002").style.width='150px';



$('#answer33946X6X44SQ002_SQ002').val(' = ' + ergebnis12 + ' EUR');



}





});

}



setTimeout("Custom_On_Load();",1050);



-->









</script><br /><span class="questionhelp"></span>







</td>

</tr>

<tr>

<td class="answer">


<table class="question" summary="Lieferservice















- an array of text responses">
<colgroup class="col-responses">

<col class="answertext" width="20%" />
<col class="odd" width="30%" />
<col class="even" width="30%" />
</colgroup>

<thead>
<tr>
<td width='20%'> </td>
<th>Prozentualen Aufschlag auf den Kaufpreis der Küche</th>
<th>Preis in EUR</th>
</tr>
</thead>


<tbody id='javatbd33946X6X44SQ001'>
<tr class="array2" id="33946X6X44SQ001">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X44SQ001' id='tbdisp33946X6X44SQ001' value='on' />
Ausprägung 1
<input type="hidden" name="java33946X6X44SQ001" id="java33946X6X44SQ001" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X44SQ001_SQ001">
<input type="hidden" name="java33946X6X44SQ001_SQ001" id="java33946X6X44SQ001_SQ001" />
<input type="text" name="33946X6X44SQ001_SQ001" id="answer33946X6X44SQ001_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X44SQ001_SQ002">
<input type="hidden" name="java33946X6X44SQ001_SQ002" id="java33946X6X44SQ001_SQ002" />
<input type="text" name="33946X6X44SQ001_SQ002" id="answer33946X6X44SQ001_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>


<tbody id='javatbd33946X6X44SQ002'>
<tr class="array1" id="33946X6X44SQ002">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X44SQ002' id='tbdisp33946X6X44SQ002' value='on' />
Ausprägung 2
<input type="hidden" name="java33946X6X44SQ002" id="java33946X6X44SQ002" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X44SQ002_SQ001">
<input type="hidden" name="java33946X6X44SQ002_SQ001" id="java33946X6X44SQ002_SQ001" />
<input type="text" name="33946X6X44SQ002_SQ001" id="answer33946X6X44SQ002_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X44SQ002_SQ002">
<input type="hidden" name="java33946X6X44SQ002_SQ002" id="java33946X6X44SQ002_SQ002" />
<input type="text" name="33946X6X44SQ002_SQ002" id="answer33946X6X44SQ002_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>
<tr class="total">
</tr>
</tbody>
</table>

<input type='hidden' name='display33946X6X44' id='display44' value='on' />


</td>

</tr>

<tr>

<td class="survey-question-help">

<img src='www.brell.de/survey/images/help.gif' alt='Help' align='left' />Hier soll eine detaillierte Leistungsbeschreibung für alle Ausprägungen hinterlegt werden.

</td>

</tr>

</table>

</div>

<div id="question49" style="display: none;" class="array-multi-flexi-text mandatory">

<table class="question-wrapper">

<tr>

<td class="questiontext">

<span class="asterisk">*</span><span class="qnumcode"> </span>Aufbauservice <script type="text/javascript" charset="utf-8">





<!--

function Custom_On_Load(){

var preis2=1100;

var ergebnis21=0;

var ergebnis22=0;

var ergebnis23=0;





$('#answer33946X6X49SQ001_SQ001').change(function() {

if ( $('#answer33946X6X49SQ001_SQ001').val() > 0 ) {



ergebnis21=preis2*0.01*$('#answer33946X6X49SQ001_SQ001').val();

document.getElementById("answer33946X6X49SQ001_SQ002").style.width='150px';



$('#answer33946X6X49SQ001_SQ002').val(' = ' + ergebnis21 + ' EUR');



}





});





$('#answer33946X6X49SQ002_SQ001').change(function() {

if ( $('#answer33946X6X49SQ002_SQ001').val() > 0 ) {



ergebnis22=preis2*0.01*$('#answer33946X6X49SQ002_SQ001').val();

document.getElementById("answer33946X6X49SQ002_SQ002").style.width='150px';



$('#answer33946X6X49SQ002_SQ002').val(' = ' + ergebnis22 + ' EUR');



}





});





$('#answer33946X6X49SQ003_SQ001').change(function() {

if ( $('#answer33946X6X49SQ003_SQ001').val() > 0 ) {



ergebnis23=preis2*0.01*$('#answer33946X6X49SQ003_SQ001').val();

document.getElementById("answer33946X6X49SQ003_SQ002").style.width='150px';



$('#answer33946X6X49SQ003_SQ002').val(' = ' + ergebnis23 + ' EUR');



}





});



}



setTimeout("Custom_On_Load();",1050);



-->









</script><br /><span class="questionhelp"></span>







</td>

</tr>

<tr>

<td class="answer">


<table class="question" summary="Aufbauservice















- an array of text responses">
<colgroup class="col-responses">

<col class="answertext" width="20%" />
<col class="odd" width="30%" />
<col class="even" width="30%" />
</colgroup>

<thead>
<tr>
<td width='20%'> </td>
<th>Prozentualen Aufschlag auf den Kaufpreis der Küche</th>
<th>Preis in EUR</th>
</tr>
</thead>


<tbody id='javatbd33946X6X49SQ001'>
<tr class="array2" id="33946X6X49SQ001">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X49SQ001' id='tbdisp33946X6X49SQ001' value='on' />
Ausprägung 1
<input type="hidden" name="java33946X6X49SQ001" id="java33946X6X49SQ001" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X49SQ001_SQ001">
<input type="hidden" name="java33946X6X49SQ001_SQ001" id="java33946X6X49SQ001_SQ001" />
<input type="text" name="33946X6X49SQ001_SQ001" id="answer33946X6X49SQ001_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X49SQ001_SQ002">
<input type="hidden" name="java33946X6X49SQ001_SQ002" id="java33946X6X49SQ001_SQ002" />
<input type="text" name="33946X6X49SQ001_SQ002" id="answer33946X6X49SQ001_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>


<tbody id='javatbd33946X6X49SQ002'>
<tr class="array1" id="33946X6X49SQ002">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X49SQ002' id='tbdisp33946X6X49SQ002' value='on' />
Ausprägung 2
<input type="hidden" name="java33946X6X49SQ002" id="java33946X6X49SQ002" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X49SQ002_SQ001">
<input type="hidden" name="java33946X6X49SQ002_SQ001" id="java33946X6X49SQ002_SQ001" />
<input type="text" name="33946X6X49SQ002_SQ001" id="answer33946X6X49SQ002_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X49SQ002_SQ002">
<input type="hidden" name="java33946X6X49SQ002_SQ002" id="java33946X6X49SQ002_SQ002" />
<input type="text" name="33946X6X49SQ002_SQ002" id="answer33946X6X49SQ002_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>


<tbody id='javatbd33946X6X49SQ003'>
<tr class="array2" id="33946X6X49SQ003">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X49SQ003' id='tbdisp33946X6X49SQ003' value='on' />
Ausprägung 3
<input type="hidden" name="java33946X6X49SQ003" id="java33946X6X49SQ003" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X49SQ003_SQ001">
<input type="hidden" name="java33946X6X49SQ003_SQ001" id="java33946X6X49SQ003_SQ001" />
<input type="text" name="33946X6X49SQ003_SQ001" id="answer33946X6X49SQ003_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X49SQ003_SQ002">
<input type="hidden" name="java33946X6X49SQ003_SQ002" id="java33946X6X49SQ003_SQ002" />
<input type="text" name="33946X6X49SQ003_SQ002" id="answer33946X6X49SQ003_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>
<tr class="total">
</tr>
</tbody>
</table>

<input type='hidden' name='display33946X6X49' id='display49' value='on' />


</td>

</tr>

<tr>

<td class="survey-question-help">

<img src='www.brell.de/survey/images/help.gif' alt='Help' align='left' /><div style="font-family: Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">

Hier soll eine detaillierte Leistungsbeschreibung für alle Ausprägungen hinterlegt werden.</div>



</td>

</tr>

</table>

</div>

<div id="question55" style="display: none;" class="array-multi-flexi-text mandatory">

<table class="question-wrapper">

<tr>

<td class="questiontext">

<span class="asterisk">*</span><span class="qnumcode"> </span>Reparationsservice <script type="text/javascript" charset="utf-8">





<!--

function Custom_On_Load(){

var preis3=1100;

var ergebnis31=0;

var ergebnis32=0;





$('#answer33946X6X55SQ001_SQ001').change(function() {

if ( $('#answer33946X6X55SQ001_SQ001').val() > 0 ) {



ergebnis31=preis3*0.01*$('#answer33946X6X55SQ001_SQ001').val();

document.getElementById("answer33946X6X55SQ001_SQ002").style.width='150px';



$('#answer33946X6X55SQ001_SQ002').val(' = ' + ergebnis31 + ' EUR');



}





});





$('#answer33946X6X55SQ002_SQ001').change(function() {

if ( $('#answer33946X6X55SQ002_SQ001').val() > 0 ) {



ergebnis32=preis3*0.01*$('#answer33946X6X55SQ002_SQ001').val();

document.getElementById("answer33946X6X55SQ002_SQ002").style.width='150px';



$('#answer33946X6X55SQ002_SQ002').val(' = ' + ergebnis32 + ' EUR');



}





});

}



setTimeout("Custom_On_Load();",1050);



-->









</script><br /><span class="questionhelp"></span>







</td>

</tr>

<tr>

<td class="answer">


<table class="question" summary="Reparationsservice















- an array of text responses">
<colgroup class="col-responses">

<col class="answertext" width="20%" />
<col class="odd" width="30%" />
<col class="even" width="30%" />
</colgroup>

<thead>
<tr>
<td width='20%'> </td>
<th>Prozentualen Aufschlag auf den Kaufpreis der Küche</th>
<th>Preis in EUR</th>
</tr>
</thead>


<tbody id='javatbd33946X6X55SQ001'>
<tr class="array2" id="33946X6X55SQ001">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X55SQ001' id='tbdisp33946X6X55SQ001' value='on' />
Ausprägung 1
<input type="hidden" name="java33946X6X55SQ001" id="java33946X6X55SQ001" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X55SQ001_SQ001">
<input type="hidden" name="java33946X6X55SQ001_SQ001" id="java33946X6X55SQ001_SQ001" />
<input type="text" name="33946X6X55SQ001_SQ001" id="answer33946X6X55SQ001_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X55SQ001_SQ002">
<input type="hidden" name="java33946X6X55SQ001_SQ002" id="java33946X6X55SQ001_SQ002" />
<input type="text" name="33946X6X55SQ001_SQ002" id="answer33946X6X55SQ001_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>


<tbody id='javatbd33946X6X55SQ002'>
<tr class="array1" id="33946X6X55SQ002">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X55SQ002' id='tbdisp33946X6X55SQ002' value='on' />
Ausprägung 1
<input type="hidden" name="java33946X6X55SQ002" id="java33946X6X55SQ002" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X55SQ002_SQ001">
<input type="hidden" name="java33946X6X55SQ002_SQ001" id="java33946X6X55SQ002_SQ001" />
<input type="text" name="33946X6X55SQ002_SQ001" id="answer33946X6X55SQ002_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X55SQ002_SQ002">
<input type="hidden" name="java33946X6X55SQ002_SQ002" id="java33946X6X55SQ002_SQ002" />
<input type="text" name="33946X6X55SQ002_SQ002" id="answer33946X6X55SQ002_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>
<tr class="total">
</tr>
</tbody>
</table>

<input type='hidden' name='display33946X6X55' id='display55' value='on' />


</td>

</tr>

<tr>

<td class="survey-question-help">

<img src='www.brell.de/survey/images/help.gif' alt='Help' align='left' /><div style="font-family: Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">

Hier soll eine detaillierte Leistungsbeschreibung für alle Ausprägungen hinterlegt werden.</div>



</td>

</tr>

</table>

</div>

<div id="question60" style="display: none;" class="array-multi-flexi-text mandatory">

<table class="question-wrapper">

<tr>

<td class="questiontext">

<span class="asterisk">*</span><span class="qnumcode"> </span>Küchen-Planungsservice <script type="text/javascript" charset="utf-8">





<!--

function Custom_On_Load(){

var preis4=1100;

var ergebnis41=0;

var ergebnis42=0;





$('#answer33946X6X60SQ001_SQ001').change(function() {

if ( $('#answer33946X6X60SQ001_SQ001').val() > 0 ) {



ergebnis41=preis4*0.01*$('#answer33946X6X60SQ001_SQ001').val();

document.getElementById("answer33946X6X60SQ001_SQ002").style.width='150px';



$('#answer33946X6X60SQ001_SQ002').val(' = ' + ergebnis41 + ' EUR');



}





});





$('#answer33946X6X60SQ002_SQ001').change(function() {

if ( $('#answer33946X6X60SQ002_SQ001').val() > 0 ) {



ergebnis42=preis4*0.01*$('#answer33946X6X60SQ002_SQ001').val();

document.getElementById("answer33946X6X60SQ002_SQ002").style.width='150px';



$('#answer33946X6X60SQ002_SQ002').val(' = ' + ergebnis42 + ' EUR');



}





});

}



setTimeout("Custom_On_Load();",1050);



-->









</script><br /><span class="questionhelp"></span>







</td>

</tr>

<tr>

<td class="answer">


<table class="question" summary="Küchen-Planungsservice















- an array of text responses">
<colgroup class="col-responses">

<col class="answertext" width="20%" />
<col class="odd" width="30%" />
<col class="even" width="30%" />
</colgroup>

<thead>
<tr>
<td width='20%'> </td>
<th>Prozentualen Aufschlag auf den Kaufpreis der Küche</th>
<th>Preis in EUR</th>
</tr>
</thead>


<tbody id='javatbd33946X6X60SQ001'>
<tr class="array2" id="33946X6X60SQ001">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X60SQ001' id='tbdisp33946X6X60SQ001' value='on' />
Ausprägung 1
<input type="hidden" name="java33946X6X60SQ001" id="java33946X6X60SQ001" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X60SQ001_SQ001">
<input type="hidden" name="java33946X6X60SQ001_SQ001" id="java33946X6X60SQ001_SQ001" />
<input type="text" name="33946X6X60SQ001_SQ001" id="answer33946X6X60SQ001_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X60SQ001_SQ002">
<input type="hidden" name="java33946X6X60SQ001_SQ002" id="java33946X6X60SQ001_SQ002" />
<input type="text" name="33946X6X60SQ001_SQ002" id="answer33946X6X60SQ001_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>


<tbody id='javatbd33946X6X60SQ002'>
<tr class="array1" id="33946X6X60SQ002">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X60SQ002' id='tbdisp33946X6X60SQ002' value='on' />
Ausprägung 2
<input type="hidden" name="java33946X6X60SQ002" id="java33946X6X60SQ002" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X60SQ002_SQ001">
<input type="hidden" name="java33946X6X60SQ002_SQ001" id="java33946X6X60SQ002_SQ001" />
<input type="text" name="33946X6X60SQ002_SQ001" id="answer33946X6X60SQ002_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X60SQ002_SQ002">
<input type="hidden" name="java33946X6X60SQ002_SQ002" id="java33946X6X60SQ002_SQ002" />
<input type="text" name="33946X6X60SQ002_SQ002" id="answer33946X6X60SQ002_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>
<tr class="total">
</tr>
</tbody>
</table>

<input type='hidden' name='display33946X6X60' id='display60' value='on' />


</td>

</tr>

<tr>

<td class="survey-question-help">

<img src='www.brell.de/survey/images/help.gif' alt='Help' align='left' /><div style="font-family: Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">

Hier soll eine detaillierte Leistungsbeschreibung für alle Ausprägungen hinterlegt werden.</div>



</td>

</tr>

</table>

</div>

<div id="question65" style="display: none;" class="array-multi-flexi-text mandatory">

<table class="question-wrapper">

<tr>

<td class="questiontext">

<span class="asterisk">*</span><span class="qnumcode"> </span>Finanzierung <script type="text/javascript" charset="utf-8">





<!--

function Custom_On_Load(){

var preis5=1100;

var ergebnis51=0;

var ergebnis52=0;





$('#answer33946X6X65SQ001_SQ001').change(function() {

if ( $('#answer33946X6X65SQ001_SQ001').val() > 0 ) {



ergebnis51=preis5*0.01*$('#answer33946X6X65SQ001_SQ001').val();

document.getElementById("answer33946X6X65SQ001_SQ002").style.width='150px';



$('#answer33946X6X65SQ001_SQ002').val(' = ' + ergebnis51 + ' EUR');



}





});





$('#answer33946X6X65SQ002_SQ001').change(function() {

if ( $('#answer33946X6X65SQ002_SQ001').val() > 0 ) {



ergebnis52=preis5*0.01*$('#answer33946X6X65SQ002_SQ001').val();

document.getElementById("answer33946X6X65SQ002_SQ002").style.width='150px';



$('#answer33946X6X65SQ002_SQ002').val(' = ' + ergebnis52 + ' EUR');



}





});

}



setTimeout("Custom_On_Load();",1050);



-->









</script><br /><span class="questionhelp"></span>







</td>

</tr>

<tr>

<td class="answer">


<table class="question" summary="Finanzierung















- an array of text responses">
<colgroup class="col-responses">

<col class="answertext" width="20%" />
<col class="odd" width="30%" />
<col class="even" width="30%" />
</colgroup>

<thead>
<tr>
<td width='20%'> </td>
<th>Prozentualen Aufschlag auf den Kaufpreis der Küche</th>
<th>Preis in EUR</th>
</tr>
</thead>


<tbody id='javatbd33946X6X65SQ001'>
<tr class="array2" id="33946X6X65SQ001">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X65SQ001' id='tbdisp33946X6X65SQ001' value='on' />
Ausprägung 1
<input type="hidden" name="java33946X6X65SQ001" id="java33946X6X65SQ001" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X65SQ001_SQ001">
<input type="hidden" name="java33946X6X65SQ001_SQ001" id="java33946X6X65SQ001_SQ001" />
<input type="text" name="33946X6X65SQ001_SQ001" id="answer33946X6X65SQ001_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X65SQ001_SQ002">
<input type="hidden" name="java33946X6X65SQ001_SQ002" id="java33946X6X65SQ001_SQ002" />
<input type="text" name="33946X6X65SQ001_SQ002" id="answer33946X6X65SQ001_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>


<tbody id='javatbd33946X6X65SQ002'>
<tr class="array1" id="33946X6X65SQ002">
<th class="answertext">
<input type='hidden' name='tbdisp33946X6X65SQ002' id='tbdisp33946X6X65SQ002' value='on' />
Ausprägung 2
<input type="hidden" name="java33946X6X65SQ002" id="java33946X6X65SQ002" value="" />
</th>
<td class="answer_cell_00SQ001">
<label for="answer33946X6X65SQ002_SQ001">
<input type="hidden" name="java33946X6X65SQ002_SQ001" id="java33946X6X65SQ002_SQ001" />
<input type="text" name="33946X6X65SQ002_SQ001" id="answer33946X6X65SQ002_SQ001" title="Prozentualen Aufschlag auf den Kaufpreis der Küche" size="20" value="" />
</label>
</td>
<td class="answer_cell_00SQ002">
<label for="answer33946X6X65SQ002_SQ002">
<input type="hidden" name="java33946X6X65SQ002_SQ002" id="java33946X6X65SQ002_SQ002" />
<input type="text" name="33946X6X65SQ002_SQ002" id="answer33946X6X65SQ002_SQ002" title="Preis in EUR" size="20" value="" />
</label>
</td>

</tr>
</tbody>
<tr class="total">
</tr>
</tbody>
</table>

<input type='hidden' name='display33946X6X65' id='display65' value='on' />


</td>

</tr>

<tr>

<td class="survey-question-help">

<img src='www.brell.de/survey/images/help.gif' alt='Help' align='left' /><div style="font-family: Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">

Hier soll eine detaillierte Leistungsbeschreibung für alle Ausprägungen hinterlegt werden.</div>



</td>

</tr>

</table>

</div>

<input type='hidden' name='lastgroup' value='33946X6' id='lastgroup' />


<!-- END THE GROUP -->
</td>

</tr>

</table>


</form>
</td>
</tr>
</table>
</div>


</body>
</html>

Thanks!!!
The administrator has disabled public write access.

Re: Automatic calculation on the same page 3 years 3 months ago #63050

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4293
  • Thank you received: 810
  • Karma: 373
Try getting rid of the Custom_On_load stuff and cleaning up the functions so they all look something like this (with the correct IDs, of course):
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var preis1=1100;
		var ergebnis11=0;		
		var ergebnis12=0;
 
		$('#answer33946X6X44SQ001_SQ001').change(function() {
 
			if ( $('#answer33946X6X44SQ001_SQ001').val() > 0 ) {
 
				ergebnis11=preis1*0.01*$('#answer33946X6X44SQ001_SQ001').val();
 
				$('#answer33946X6X44SQ001_SQ002').val(' = ' + ergebnis11 + ' EUR').css({'width':'150px'});
 
			}
		});
 
 
		$('#answer33946X6X44SQ002_SQ001').change(function() {
 
				if ( $('#answer33946X6X44SQ002_SQ001').val() > 0 ) {
 
				ergebnis12=preis1*0.01*$('#answer33946X6X44SQ002_SQ001').val();
 
				$('#answer33946X6X44SQ002_SQ002').val(' = ' + ergebnis12 + ' EUR').css({'width':'150px'});
 
			}
		});
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 3 years 3 months ago by tpartner.
The administrator has disabled public write access.

Re: Automatic calculation on the same page 3 years 3 months ago #63071

  • alex2610
  • alex2610's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
Thanks Tony a lot for your help!

The problem was apparently that multiple functions with the same name were included...changing custom_on_load to custom_on_load1, custom_on_load2 etc. helped.
The administrator has disabled public write access.

Re: Automatic calculation on the same page 3 years 3 months ago #63092

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4293
  • Thank you received: 810
  • Karma: 373
I don't understand why you're using those with delays.

You can wrap all of those functions in the jQuery $(document).ready(function() which prevents them from firing until the page is completely loaded.

$(document).ready(function() can be used as many times as you like on a page.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 1.118 seconds
Donation Image