[pmwiki-devel] How to create a GUIEdit button using Javascript

Randy Brown randy at brownragfilms.com
Fri Sep 19 01:31:47 CDT 2014


I would appreciate help from someone who knows Javascript (which I don't). 

I'm creating a GUIEdit button that adds a markup expression containing a random number and text containing the same number. 

If I select in my edit form:

My text

and then click my guiedit button, I want a result like this:

{(mymarkupexpression 2 "My text")}
The above number is 2

Here's approximately what I've written to do this. Unfortunately, what I wrote uses the same number for each page load rather than for each button click. I want the number to change with each button click:

$num = rand ( 1, 1000 ); 
SDVA($GUIButtons, array(
  'mybutton'       => array(8000, "{(mymarkupexpression ".$num." "", "")}\\nThe above number is ".$num."\\n", '$[Default text if none selected]',
                  '$GUIButtonDirUrlFmt/mybuttonicon.png"$[DoXYZ]"','')
));
$HTMLHeaderFmt['DoXYZ']= <<<EOF
<script type='text/javascript'><!--
function DoXYZ() {

I IMAGINE THERE IS A WAY TO DO THIS IN JAVASCRIPT

  return;
}
//--></script>
  
EOF;

Thanks,

Randy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-devel/attachments/20140919/0adf24e1/attachment.html>


More information about the pmwiki-devel mailing list