...

View Full Version : Newsletter Preview Problem



phily245
07-08-2011, 10:42 AM
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:

<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?

BulletTimeBill
07-08-2011, 01:31 PM
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.

phily245
07-08-2011, 02:01 PM
You were right, I was missing this bit of code from my header:

<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:

<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:

<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?

BulletTimeBill
07-09-2011, 01:22 AM
For that to work you need a form with the name "add_form". Which I do not see in your code. Is it there?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum