...

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



joshlobe
07-23-2012, 03: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:



<head>
<?php
// 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>
</head>

<body>
<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">
<p>{#shortcodes_dlg.title}</p>
<img src="img/wordpress-shortcode.png" width="128" height="128" alt="Youtube" />
</div>
<div class="yinstr">
<p>{#shortcodes_dlg.instr}</p>
</div>

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

// 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>";

?>

</div>


And here is the javascript file used with the popup:



tinyMCEPopup.requireLangPack();

var ShortcodesDialog = {

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

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

tinyMCEPopup.close();
}
};

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


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


ed.addCommand('mceShortcodes', function() {
ed.windowManager.open({
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