Script in my child form:
<script language="JavaScript" type="text/javascript"> function SetData() { // form validation // var frmvalidator = new Validator("myForm"); // frmvalidator.addValidation("name","req","Please enter Account Name"); // get the new dialog values var str1 = document.getElementById("name").value; var winArgs = str1; // pass the values back as arguments window.returnValue = winArgs; window.close(); document.myForm.submit(); } </script>
Script in my parent form:
<% @account_head= current_company.account_heads.find_by_name("Sundry Debtors")%> <script type="text/javascript"> function OpenDialog() { var winSettings = 'center:yes;resizable:no;help:yes;status:no;dialogWidth:450px;dialogHeight:200px'; // return the dialog control values after passing them as a parameter winArgs = window.showModalDialog('<%= "/accounts/new?account_head_id=#{@account_head.id} #man" %>', winSettings); if(winArgs == null) { window.alert("no data returned!"); } else { // set the values from what returned document.getElementById("to_account_auto_complete").value = winArgs; } } </script>
This is work, but not the way I want, anyone, if they find a good solution, suggest it.
source share