Difference between revisions of "Show language selector page"

From Catglobe Wiki
Jump to: navigation, search
m (HTML Code)
(Solution)
Line 54: Line 54:
 
       </table>
 
       </table>
 
     </div>
 
     </div>
 +
</source>
 +
===Javascript===
 +
<source lang=javascript>
 +
quest.myOnInit = function()
 +
{
 +
  $('img').css("cursor","pointer");
 +
  $('<input type="hidden">')
 +
  .attr('id', 'languageSelector')
 +
  .attr('name', 'languageselector')
 +
  .appendTo($('#page_question_text')); 
 +
  $('#page_question_text').append($("<input type='hidden'>").attr('name','QUESTION.D_CurrentLanguage'));
 +
}
 +
 +
Question =
 +
{
 +
 
 +
  onLanguageSelect: function(option)
 +
  {
 +
      $("input[name='QUESTION.D_CurrentLanguage']").val(option);
 +
      var isoCode;
 +
      switch(option)
 +
      {
 +
        case 1:
 +
            isoCode = "en-UK";
 +
            break;
 +
        case 2:
 +
            isoCode = "en-US";
 +
            break;
 +
        case 3:
 +
            isoCode = "fr-FR";
 +
            break;
 +
        case 4:
 +
            isoCode = "de-DE";
 +
            break;
 +
        case 5:
 +
            isoCode = "nl-NL";
 +
            break;
 +
        default:
 +
            break;
 +
      }
 +
 +
      $('#languageSelector').val(isoCode);
 +
 
 +
      var myurl =  $("form").attr("action");
 +
      var mydata = "dir=changelanguage&languageselector="+isoCode;
 +
      $.ajax({
 +
        type: "POST",
 +
        url: myurl,
 +
        data: mydata,
 +
        success: function(msg)
 +
        {
 +
            document.query.dir.value = "next";
 +
            document.query.submit();
 +
        },
 +
        error:function(msg)
 +
        {
 +
        }
 +
      }); 
 +
 +
  }
 +
}
 
</source>
 
</source>

Revision as of 07:39, 10 July 2009

Introduction

In order to have a nicer way of letting the respondents

Solution

HTML Code

<div align="center">
      <table>
        <tr>
          <td>
            <img style="border: 0" height="50" width="50" src="../../Images/GetImage.aspx?rid=9e152350-ae1e-47c7-bf0d-0a6f07df3679" onclick="Question.onLanguageSelect(1);">
            
          </td>
          <td>
            Welcome, please choose your language (United Kingdom)
          </td>
        </tr>
        <tr>
          <td>
            <img style="border: 0" height="50" width="50" src="../../Images/GetImage.aspx?rid=06ac1811-1aa5-4b19-9186-b46153d91106" onclick="Question.onLanguageSelect(2);">
            
          </td>
          <td>
            Welcome, please choose your language (United States)
          </td>
        </tr>
        <tr>
          <td>
            <img style="border: 0" height="50" width="50" src="../../Images/GetImage.aspx?rid=a3dd8263-817b-4f11-bd87-defb13b7cf68" onclick="Question.onLanguageSelect(3);">
            
          </td>
          <td>
            Bienvenue - Choisissez votre pays (France)
          </td>
        </tr>
        <tr>
          <td>
            <img style="border: 0" height="50" width="50" src="../../Images/GetImage.aspx?rid=e9e6fa0f-af1b-401b-89a1-5d5a9535e13c" onclick="Question.onLanguageSelect(4);">
            
          </td>
          <td>
            Welcome, please choose your language (Deutschland)
          </td>
        </tr>
        <tr>
          <td>
            <img style="border: 0" height="50" width="50" src="../../Images/GetImage.aspx?rid=4057e800-0de6-43a1-b737-dbe0642cd414" onclick="Question.onLanguageSelect(5);">
            
          </td>
          <td>
            Welcome, please choose your language (Nederland)
          </td>
        </tr>
      </table>
    </div>

Javascript

quest.myOnInit = function()
{
   $('img').css("cursor","pointer");
   $('<input type="hidden">')
   .attr('id', 'languageSelector')
   .attr('name', 'languageselector')
   .appendTo($('#page_question_text'));   
   $('#page_question_text').append($("<input type='hidden'>").attr('name','QUESTION.D_CurrentLanguage'));
}

Question =
{
   
   onLanguageSelect: function(option)
   {
      $("input[name='QUESTION.D_CurrentLanguage']").val(option);
      var isoCode;
      switch(option)
      {
         case 1:
            isoCode = "en-UK";
            break;
         case 2:
            isoCode = "en-US";
            break;
         case 3:
            isoCode = "fr-FR";
            break;
         case 4:
            isoCode = "de-DE";
            break;
         case 5:
            isoCode = "nl-NL";
            break;
         default:
            break;
      }

      $('#languageSelector').val(isoCode);
   
      var myurl =  $("form").attr("action");
      var mydata = "dir=changelanguage&languageselector="+isoCode;
      $.ajax({
         type: "POST",
         url: myurl,
         data: mydata,
         success: function(msg)
         {
            document.query.dir.value = "next";
            document.query.submit();
         },
         error:function(msg)
         {
         }
      });  

   }
}