ModalDialog – part 2

…this post was published on 2012 February 16.

Yes, right,  the request was: I need to show different column’s value  based on different selected column. In this case, the will looks like bellow

The main difference, is that in the script for function open_modaldialog

   function open_modaldialog(continent,country,capital)
     {
      if (continent == ‘Europe’)
        {
         alert(“you selected: “+continent);
        var selected_column=”You selected Europe: The selected country is”;
       var passed_value=continent+’^’+country+’^’+selected_column;
      }
     else
     {
     alert(“you selected: “+continent);
    var selected_column=”You selected other continent: The capital for “+country;
    var passed_value=continent+’^’+capital+’^’+selected_column;
    }

   ( … the rest of code, deleted, is the same as in previous example )
i inserted a condition if (continent ==’Europe’)
  Based on it, you see the message just after click-ing the continet, with your choice, and also i prepared the value for the text ( which will appear in the modal window ) and the value of the field. Next , I will call a new modaldialog window – only to preserve the precedent example, and in that windowi have keeped only one field ( for country / capital ), which i Id-it with “value_column”, and a text with id=”seleted_column”.
 The code used when this modal dialog load, is this one bellow
    <script type=”text/javascript” >
    _spBodyOnLoadFunctionNames.push(“fill_the_fields”);
     function fill_the_fields()
       {
       var passed_value=window.frameElement.dialogArgs.split(‘^’);
       document.getElementById(‘continent’).value=passed_value[0];
       document.getElementById(‘selected_column’).innerHTML=passed_value[2];
       document.getElementById(‘value_column’).value=passed_value[1];
       } 
   </script>
This entry was posted in Coding, Javascript, Sharepoint. Bookmark the permalink.