Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help, applying costs to a number of languages

    Hi all,

    I was wondering if you could help me out with some code.

    This is the 1st page of code

    Code:
    <html>
    
    <head>
    <title>Symantec Quote Calculator</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    window.resizeTo(400, 600)
    function zxcES(zxcele,zxcstyle,zxcp,zxctxt){
    if (typeof(zxcele)=='string'){ zxcele=document.createElement(zxcele); }
    for (key in zxcstyle){ zxcele.style[key]=zxcstyle[key]; }
    if (zxcp){ zxcp.appendChild(zxcele); }
    if (zxctxt){ zxcele.appendChild(document.createTextNode(zxctxt)); }
    return zxcele;
    }
    
    function zxcAddLanguage(zxcobj,zxccount,zxcsel,zxccost,zxcselected){
     var zxcfrm=zxcobj.form;
     var zxccnt=zxcfrm[zxccount];
     zxccnt.value=zxccnt.value.replace(/\D/g,'');
     var zxcsel=zxcfrm[zxcsel];
     var zxcindex=zxcsel.selectedIndex;
     var zxcoption=zxcsel.options[zxcindex];
     var zxcselected=document.getElementById(zxcselected);
     var zxcclds=zxcselected.childNodes;
     var zxcadd=true;
     for (var zxc0=0;zxc0<zxcclds.length;zxc0++){
      if (zxcclds[zxc0].firstChild.data==zxcoption.text){
       zxcselected.removeChild(zxcclds[zxc0]);
       zxcES(zxcoption,{backgroundColor:'#ffffff'});
       zxcadd=false;
       break;
      }
     }
     if (zxcindex>0&&zxcadd){
      zxcES('DIV',{position:'relative',left:'0px',height:'10px',backgroundColor:'#FFD700',fontSize:'15px', borderBottom:'solid black 1px',paddingLeft:'5px',paddingRight:'5px',paddingBottom:'5px',paddingTop:'5px'},zxcselected,zxcoption.text).cost=zxcoption.value;
      zxcES(zxcselected,{border:'solid black 1px',borderBottom:'0px'});
      zxcES(zxcoption,{backgroundColor:'#FFFFCC'});
     }
     zxcsel.selectedIndex=0;
     var zxctotal=0;
     if (zxccnt.value.length>0){
      zxcclds=zxcselected.childNodes;
      for (var zxc1=0;zxc1<zxcclds.length;zxc1++){
       zxctotal+=zxcclds[zxc1].cost*zxccnt.value;
      }
     }
     zxcfrm[zxccost].value=zxctotal.toFixed(2);
    }
    
    function zxcNext(zxcfrm){
     var zxccnt=zxcfrm.count.value;
     var zxccost=zxcfrm.cost.value;
     var zxcdivs=document.getElementById('selected').childNodes
     var zxclanguages='';
     for (var zxc0=0;zxc0<zxcdivs.length;zxc0++){
      zxclanguages+=zxcdivs[zxc0].firstChild.data+':';
     }
     if (zxccnt<1||zxclanguages==''){
      alert('Please select the Number of Words and the Language to Translate');
      return;
     }
     zxclanguages+='^'+zxccnt+'^'+zxccost;
     zxcSetFormCookie(zxclanguages);
    }
    
    
    
    //-->
    </script>
    
    <script language="JavaScript" type="text/javascript">
    <!--
    
    var zxcDays=1;       // The cookie will be available on revisits for a specified number of days
    var zxcCookie='Language1';        // The Cookie name
    
    
    function zxcSetFormCookie(zxcvalue){
     document.cookie=zxcCookie+"="+encodeURI(zxcvalue)+";expires="+zxcExp+";path=/;"
     window.top.location="Quote Tool_1.html"
    }
    
    var zxcExp=new Date(new Date().getTime()+zxcDays*86400000).toGMTString();
    
    function zxcCookieValue(){
     zxcString=zxcGetCookie(zxcCookie);
    document.Show.Show0.value=zxcGetCookie(zxcCookie)
    }
    
    function zxcGetCookie(name) {
     var zxcst=document.cookie.indexOf(name+"=");
     var zxclen=zxcst+name.length+1;
     if ((!zxcst)&&(name != document.cookie.substring(0,name.length))) return null;
     if (zxcst==-1) return null;
     var zxcend=document.cookie.indexOf(";",zxclen);
     if (zxcend==-1) zxcend=document.cookie.length;
     return decodeURI(document.cookie.substring(zxclen,zxcend));
    }
    
    //-->
    </script>
    
    <style type="text/css">
    
    body
    {
    width: 800px;
    height: 600px;
    }
    
    fieldset.formFieldSet {
    padding: 10px;
    width: 325px;
    border:solid #000000;
    }
    <!--
    .style2 {font-family: "Symantec Sans Medium"}
    -->
    </style>
    </head>
    
    <body bgcolor="#FFFF00" >
    <fieldset class="formFieldSet">
    <center>
    <form action="Quote Tool_1.html" onsubmit="this.YourHiddenElementName.value=cost()" >
    <span class="style2">Please Input the Word Count Here: </span>
    <input name="count" type="text" size="7" onkeyup="zxcAddLanguage(this,'count','sel','cost','selected')">
    <br><br>
    <select name="sel" onchange="zxcAddLanguage(this,'count','sel','cost','selected')" >
    <option value="" >Select Languages</option>
    <option value="0.40" >Arabic</option>
    <option value="0.14" >Brazilian</option>
    <option value="0.12" >Czech</option>
    <option value="0.27" >Danish</option>
    <option value="0.12" >Dutch</option>
    <option value="0.12" >Finnish</option>
    <option value="0.22" >French</option>
    <option value="0.19" >German</option>
    <option value="0.24" >Greek</option>
    <option value="0.26" >Hebrew</option>
    <option value="0.11" >Hungarian</option>
    <option value="0.19" >Italian</option>
    <option value="0.27" >Norwegian</option>
    <option value="0.09" >Polish</option>
    <option value="0.22" >Portuguese</option>
    <option value="0.06" >Russian</option>
    <option value="0.12" >Spanish</option>
    <option value="0.12" >Spanish Latin</option>
    <option value="0.29" >Swedish</option>
    <option value="0.12" >Turkish</option>
    </select>
    <br>
    <br>
    <span class="style2">
    Selected Languages Will Appear Below.
    To remove languages from the list, simply select the language again from the drop-down box.</span>
    <br><br>
    <div id="selected" style="position:relative;width:100px;" ></div>
    <br><br>
    <span class="style2">Total Cost In Euros</span>:
    <input name="cost" type="text" size="7" onkeyup="return false;">
    <br><br>
    <input type="button" value="Next" onclick="zxcNext(this.form);" >
    <input type="reset" value="Clear">
    
    </form>
    
    <br><br>
    <img src="symyellowback.png" width="279" height="71">
    </form>
    </center>
    </body>
    and here is the second page of code:

    Code:
    <html>
    
    <head>
    <title>Symantec Quote Calculator</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    window.resizeTo(400, 600)
    function zxcES(zxcele,zxcstyle,zxcp,zxctxt){
     if (typeof(zxcele)=='string'){ zxcele=document.createElement(zxcele); }
     for (key in zxcstyle){ zxcele.style[key]=zxcstyle[key]; }
     if (zxcp){ zxcp.appendChild(zxcele); }
     if (zxctxt){ zxcele.appendChild(document.createTextNode(zxctxt)); }
     return zxcele;
    }
    
    function zxcNext(zxcfrm){
     var zxccnt=zxcfrm.count.value;
     var zxccost=zxcfrm.cost.value;
     var zxcdivs=document.getElementById('selected').childNodes
     var zxclanguages='';
     for (var zxc0=0;zxc0<zxcdivs.length;zxc0++){
      zxclanguages+=zxcdivs[zxc0].firstChild.data+':';
     }
     if (zxccnt<1||zxclanguages==''){
      alert('Please select the Number of Words and the Language to Translate');
      return;
     }
     zxclanguages+='^'+zxccnt+'^'+zxccost;
    }
    
    function zxcReview(zxcrad){
     var zxcfrm=zxcrad.form;
     zxcfrm.cost.value=zxcfrm.hiddencost.value*1+zxcrad.value*(zxcLanguages.length-1);
    }
    
    //-->
    </script>
    
    <script language="JavaScript" type="text/javascript">
    <!--
    
    var zxcDays=1;       // The cookie will be available on revisits for a specified number of days
    var zxcCookie='Language1';        // The Cookie name
    
    
    function zxcSetFormCookie(zxcvalue){
     document.cookie=zxcCookie+"="+encodeURI(zxcvalue)+";expires="+zxcExp+";path=/;"
    }
    
    var zxcExp=new Date(new Date().getTime()+zxcDays*86400000).toGMTString();
    var zxcLanguages;
    
    function zxcCookieValue(){
     var zxcstring=zxcGetCookie(zxcCookie).split('^');
     var zxcfrm=document.LanguageForm;
     zxcfrm.count.value=zxcstring[1];
     zxcfrm.cost.value=zxcstring[2];
     zxcfrm.hiddencost.value=zxcstring[2];
     zxcLanguages=zxcstring[0].split(':');
     var zxcselected=document.getElementById('selected');
     for (var zxc0=0;zxc0<zxcLanguages.length-1;zxc0++){
      zxcES('DIV',{position:'relative',left:'0px',height:'21px',backgroundColor:'#FFD700',fontSize:'20px', borderBottom:'solid black 1px',paddingLeft:'5px',paddingRight:'5px',paddingBottom:'5px',paddingTop:'5px'},zxcselected,zxcLanguages[zxc0]);
     }
    }
    
    function zxcGetCookie(name) {
     var zxcst=document.cookie.indexOf(name+"=");
     var zxclen=zxcst+name.length+1;
     if ((!zxcst)&&(name != document.cookie.substring(0,name.length))) return null;
     if (zxcst==-1) return null;
     var zxcend=document.cookie.indexOf(";",zxclen);
     if (zxcend==-1) zxcend=document.cookie.length;
     return decodeURI(document.cookie.substring(zxclen,zxcend));
    }
    
    //-->
    </script>
    
    <style type="text/css">
    
    body
    {
    width: 800px;
    height: 600px;
    }
    
    fieldset.formFieldSet {
    padding: 10px;
    width: 325px;
    border:solid #000000;
    }
    <!--
    .style2 {font-family: "Symantec Sans Medium"}
    -->
    </style>
    </head>
    
    <body bgcolor="#FFFF00" onload="zxcCookieValue();">
    <fieldset class="formFieldSet">
    <center>
    
    <form name="LanguageForm" action="DTP.html" onsubmit="this.YourHiddenElementName.value=cost()" >
    <span class="style2">You have specified Words: </span>
    <input name="count" type="text" size="7" onkeyup="return false;">
    <br><br>
    <br>
    <br>
    <span class="style2">
    You have selected the following Languages.
    </span>
    <br><br>
    <div id="selected" style="position:relative;width:100px;" ></div>
    <br><br>
    <span class="style2">Total Cost In Euros</span>:
    <input name="cost" type="text" size="7" onkeyup="return false;">
    <input name="hiddencost" type="hidden" size="7">
    <br><br>
    Do you need external review? 
    <input type="radio" value="30" name="review" onclick="zxcReview(this);" >yes | no<input type="radio" value="0" name="review" onclick="zxcReview(this);">
    <br><br>
    Does document need DTP? 
    <input type="radio" id="r1" name="rad1"onclick="document.getElementById('clairef').style.display ='block'; ">Yes 
    <input type="radio" id="r1" name="rad1" onclick="document.getElementById('clairef').style.display ='none'; ">No<br>
    <span id="clairef" style="display:none;">
    <br><br>
    
    How many PDF Pages does your document have?
    <br><br>
    <select name="sel"  >
    <option value="" >Select Pages</option>
    <option value="50" >1 - 5</option>
    <option value="100" >5 - 10</option>
    <option value="150" >10 - 15</option>
    <option value="200" >15 - 20</option>
    <option value="300" >20+</option>
    </span>
    <br>
    <div id="adiv"></div>
    <br><br>
    </form>
    
    <br><br>
    <img src="symyellowback.png" width="279" height="71">
    </form>
    </center>
    </body>
    Everything works up to the part: Do you need External review.

    I just need to get the DTP part working. Each number of pages in the DTP part has a different cost. and if the user chooses say... 1 - 5, then a cost of 50 is applied to each of the languages specified. Can you help me out with this?

    Many thanks

    Cup

  • #2
    Regular Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    223
    Thanks
    0
    Thanked 14 Times in 14 Posts
    This code is posted "as is" and I expect you to test it thoroughly. I do not accept any responsibilty for use of this code.

    That said, I have tested it quite well and seems to work OK! It also means you are free to pass this code off as your own!!

    Code:
    <html>
    
    <head>
    <title>Symantec Quote Calculator</title>
    <script type="text/javascript">
    <!--
    window.resizeTo(400, 600)
    function zxcES(zxcele,zxcstyle,zxcp,zxctxt){
    	if (typeof(zxcele)=='string'){ zxcele=document.createElement(zxcele); }
    	for (key in zxcstyle){ zxcele.style[key]=zxcstyle[key]; }
    	if (zxcp){ zxcp.appendChild(zxcele); }
    	if (zxctxt){ zxcele.appendChild(document.createTextNode(zxctxt)); }
    	return zxcele;
    }
    
    function zxcNext(zxcfrm){
     var zxccnt=zxcfrm.count.value;
     var zxccost=zxcfrm.cost.value;
     var zxcdivs=document.getElementById('selected').childNodes
     var zxclanguages='';
     for (var zxc0=0;zxc0<zxcdivs.length;zxc0++){
      zxclanguages+=zxcdivs[zxc0].firstChild.data+':';
     }
     if (zxccnt<1||zxclanguages==''){
      alert('Please select the Number of Words and the Language to Translate');
      return;
     }
     zxclanguages+='^'+zxccnt+'^'+zxccost;
    
    }
    
    var lastZxcReview=0;
    function zxcReview(zxcrad){
     var zxcfrm=zxcrad.form;
     zxcfrm.cost.value=zxcfrm.hiddencost.value*1-lastZxcReview*(zxcLanguages.length-1);
     zxcfrm.cost.value=zxcfrm.hiddencost.value*1+zxcrad.value*(zxcLanguages.length-1);
     zxcfrm.cost.value=parseFloat(zxcfrm.cost.value)+lastPdfAmount
     lastZxcReview=zxcrad.value;
    }
    
    var lastPdfAmount=0;
    function pdfCost(obj){
    	var zxcfrm=obj.form;
    	pdfAmount = parseInt(obj.options[obj.selectedIndex].value);
    	
    	zxcfrm.cost.value=parseFloat(zxcfrm.cost.value)-lastPdfAmount;
    	zxcfrm.cost.value=parseFloat(zxcfrm.cost.value)+pdfAmount;
    	lastPdfAmount=pdfAmount
    }
    
    function resetDtp(){
    	document.getElementById('clairef').style.display ='none';
    	var zxcfrm=document.LanguageForm;
    	zxcfrm.sel.selectedIndex=0;
    	zxcfrm.cost.value=parseFloat(zxcfrm.cost.value)-lastPdfAmount;
    	lastPdfAmount=0;
    }
    
    var zxcDays=1;       // The cookie will be available on revisits for a specified number of days
    var zxcCookie='Language1';        // The Cookie name
    
    
    function zxcSetFormCookie(zxcvalue){
     document.cookie=zxcCookie+"="+encodeURI(zxcvalue)+";expires="+zxcExp+";path=/;"
    
    }
    
    var zxcExp=new Date(new Date().getTime()+zxcDays*86400000).toGMTString();
    var zxcLanguages;
    
    function zxcCookieValue(){
     var zxcstring=zxcGetCookie(zxcCookie).split('^');
     var zxcfrm=document.LanguageForm;
     zxcfrm.count.value=zxcstring[1];
     zxcfrm.cost.value=zxcstring[2];
     zxcfrm.hiddencost.value=zxcstring[2];
     zxcLanguages=zxcstring[0].split(':');
     var zxcselected=document.getElementById('selected');
     for (var zxc0=0;zxc0<zxcLanguages.length-1;zxc0++){
      zxcES('DIV',{position:'relative',left:'0px',height:'21px',backgroundColor:'#FFD700',fontSize:'20px', borderBottom:'solid black 1px',paddingLeft:'5px',paddingRight:'5px',paddingBottom:'5px',paddingTop:'5px'},zxcselected,zxcLanguages[zxc0]);
     }
    }
    
    function zxcGetCookie(name) {
     var zxcst=document.cookie.indexOf(name+"=");
     var zxclen=zxcst+name.length+1;
     if ((!zxcst)&&(name != document.cookie.substring(0,name.length))) return null;
     if (zxcst==-1) return null;
     var zxcend=document.cookie.indexOf(";",zxclen);
     if (zxcend==-1) zxcend=document.cookie.length;
     return decodeURI(document.cookie.substring(zxclen,zxcend));
    }
    
    //-->
    </script>
    
    <style type="text/css">
    
    body
    {
    width: 800px;
    height: 600px;
    }
    
    fieldset.formFieldSet {
    padding: 10px;
    width: 325px;
    border:solid #000000;
    }
    <!--
    .style2 {font-family: "Symantec Sans Medium"}
    -->
    </style>
    </head>
    
    <body bgcolor="#FFFF00" onload="zxcCookieValue();">
    <fieldset class="formFieldSet">
    <center>
    <form name="LanguageForm" action="DTP.html" onsubmit="this.YourHiddenElementName.value=cost()" >
    <span class="style2">You have specified Words: </span>
    <input name="count" type="text" size="7" onkeyup="return false;">
    <br><br>
    <br>
    <br>
    <span class="style2">
    You have selected the following Languages.
    </span>
    <br><br>
    <div id="selected" style="position:relative;width:100px;" ></div>
    <br><br>
    <span class="style2">Total Cost In Euros</span>:
    <input name="cost" type="text" size="7" onkeyup="return false;">
    <input name="hiddencost" type="hidden" size="7">
    <br><br>
    Do you need external review? 
    <input type="radio" value="30" name="review" onclick="zxcReview(this);" >yes | no<input type="radio" value="0" name="review" onclick="zxcReview(this);">
    <br><br>
    Does document need DTP? 
    <input type="radio" id="r1" name="rad1"onclick="document.getElementById('clairef').style.display ='block'; ">Yes 
    <input type="radio" id="r1" name="rad1" onclick="resetDtp()">No<br>
    <span id="clairef" style="display:none;">
    <br><br>
    
    How many PDF Pages does your document have?
    <br><br>
    <select name="sel" onchange="pdfCost(this)" >
    <option value="0" >Select Pages</option>
    <option value="50" >1 - 5</option>
    <option value="100" >5 - 10</option>
    <option value="150" >10 - 15</option>
    <option value="200" >15 - 20</option>
    <option value="300" >20+</option>
    </span>
    <br>
    <div id="adiv"></div>
    <br><br>
    </form>
    
    <br><br>
    <img src="symyellowback.png" width="279" height="71">
    </form>
    </center>
    </body>
    Have fun.

  • #3
    New Coder
    Join Date
    Feb 2007
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi there,

    This is great thank you very much. I really appreciate it :-)

    Cup


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •