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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Newsletter Preview Problem

    Hi,

    I've been inherited a website from another web developer and I need to fix his code. In one part of the admin system, the user selects a template for the newsletter to use, types the subject and body text into a form, then submits it using a submit button. There is no problem with this code and the user is able to send newsletters out using the standard template (there is only one template). However, they require a preview button to check it looks how they want it to on the template. to get to the preview page (preview_mailing.php?template=1), there is a Javascript preview button, which uses the following code:
    Code:
    <script>
    				function get_radio_value()
    				{
    				for (var i=0; i < document.add_form.template.length; i++)
    				   {
    				   if (document.add_form.template[i].checked)
    					  {
    					  return rad_val = document.add_form.template[i].value;
    					  }
    				   }
    				}
    
    				</script>
    
                <a href="javascript:;" title="Preview" target="_self" class="button" onclick="MM_openBrWindow('preview_mailing.php?template=' + get_radio_value(),'preview','scrollbars=yes,width=600,height=800');return false">Preview</a>			
        <br/>
    When you click on this button, however, it does absolutely nothing and shows javascript:; as the link, but I'm sure this is what it is meant to show as the link?
    Last edited by phily245; 07-08-2011 at 12:17 PM.

  • #2
    Regular Coder
    Join Date
    May 2010
    Location
    Bathurst, Australia
    Posts
    180
    Thanks
    1
    Thanked 22 Times in 22 Posts
    No, that's not the problem. Though i'm pretty sure it's not necessary. The problem would be somewhere on that onclick. Check you have what ever scripts are necessary to call MM_openBrWindow. Someone posted something with that not too long ago, i forget if it was part of jQuery or not. Also check that preview_mailing.php is the correct url and that it's passing the right variables.
    Disclaimer: I'm hungover 70% of the time i'm on here, any information given may not be correct, or even legible.

  • #3
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You were right, I was missing this bit of code from my header:
    Code:
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
      return false;
    }
    //-->
    </script>
    The popup now works, however the value isn't being passed properly between the radio button which selects the templates and the Javascript, so it now ouputs a url of "www.mysite.com/admin/preview_mailing.php?template=undefined". Here is the html result of the php which adds the radio buttons:
    Code:
    <label for="cat">Newsletter Template<br /><br /> 
                    <div id="div"><input type="radio" name="template" value="1" id="template"checked="checked" /> 
         Standard<br/><img src="../newsletter/standard.gif" width="100" style="border: 2px #D50072 solid;"/></div>                
                    </label>
    This should be passed to the popup opener by this script:
    Code:
    <script>
    				function get_radio_value()
    				{
    				for (var i=0; i < document.add_form.template.length; i++)
    				   {
    				   if (document.add_form.template[i].checked)
    					  {
    					  return rad_val = document.add_form.template[i].value;
    					  }
    				   }
    				}
    
    				</script>
    Any ideas?

  • #4
    Regular Coder
    Join Date
    May 2010
    Location
    Bathurst, Australia
    Posts
    180
    Thanks
    1
    Thanked 22 Times in 22 Posts
    For that to work you need a form with the name "add_form". Which I do not see in your code. Is it there?
    Disclaimer: I'm hungover 70% of the time i'm on here, any information given may not be correct, or even legible.


  •  

    Tags for this Thread

    Posting Permissions

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