View Full Version : Get Variable from Form with generated PHP list

07-23-2012, 04:33 PM
I'm so stuck. I'm using tinymce with wordpress. I have created a custom button which, when clicked, opens a popup with a generated list of shortcodes from a global variable.

I am trying to insert either the value of the selected radio box from the popup window, into the content editor.

Here is most of the code from the popup window file:

// Hook into Wordpress so we can use all the custom functions and global variables
$file = dirname(__FILE__);
$file = substr($file, 0, stripos($file, "wp-content") );
require( $file . "/wp-load.php");
//require( $file . "/wp-admin/admin.php");
//require( $file . "/wp-admin/includes/admin.php");
<script type="text/javascript" language="javascript">
var shortcodeTag = "<?php
$selected_radio = isset($_POST['jwl_shortcode_js']);
echo '['.$selected_radio.']'.' '.'[/'.$selected_radio.']';

<script type="text/javascript" src="../tinymce/tiny_mce_popup.js"></script>
<script type="text/javascript" src="js/dialog.js"></script>
<div class="y_logo_contener">
<img src="img/wordpress-shortcode.png" width="128" height="128" alt="Youtube" />
<div class="yinstr">

<form onSubmit="ShortcodesDialog.insert();return false;" action="#" method="post">
<div class="mceActionPanel">

// Now we can use Wordpress
global $shortcode_tags;

echo "<div><table id='shortcodes_table'>";
foreach($shortcode_tags as $tagname=>$tag) {
echo "<tr><td><input type='radio' id='[".$tagname."]' onclick='ShortcodesDialog.insert();' name='jwl_shortcode_js' value='[".$tagname."]' />[$tagname]</td></tr>";
echo "</table></div>";



And here is the javascript file used with the popup:


var ShortcodesDialog = {

insert : function(file, title) {
var ed = tinyMCEPopup.editor, dom = ed.dom;

tinyMCEPopup.execCommand('mceInsertContent', false, shortcodeTag);


tinyMCEPopup.onInit.add(ShortcodesDialog.init, ShortcodesDialog);

Lastly, here is a snippet from the editor_plugin.js file:

ed.addCommand('mceShortcodes', function() {
file : url + '/shortcodes.php',
width : 640 + ed.getLang('shortcodes.delta_width', 0),
height : 600 + ed.getLang('shortcodes.delta_height', 0),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument

Please help.... and thank you.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum