Javascript problem

Old and generally outdated discussions, with the rare hidden gem. Enter at your own risk.

Moderators: Haplo, Lead Developers

Locked
User avatar
Gez
Developer Emeritus
Posts: 3020
Joined: Fri Jul 22, 2005 8:40 pm

Javascript problem

Post by Gez »

Hey, I'm wondering what I'm doing wrong.

I'm customizing a wiki engine (derived from Wakka, for those who know), and adding a snazzy-looking little editor toolbar I found for it somewhere.

I'm wanting to add on that toolbar the submit button and preview buttons. But they don't work.

The code looks like this:

Code: Select all

<form id="ACEditor" name="ACEditor" action="http://localhost/wikini/wakka.php?wiki=TestPage/edit" method="post">
<input type="hidden" name="wiki" value="TestPage/edit" />
<input type="hidden" name="previous" value="561" />

  <div id="toolbar"> 
    <img class="buttons" onmouseover="mouseover(this);" onmouseout="mouseout(this);" onmousedown="mousedown(this);" onmouseup="mouseup(this);" onclick="wrapSelection(thisForm.body,'**','**');" src="UI/bold.gif" title="Bold selected text  ( Ctrl-Shift-b )">

... lots of other buttons, I'm snipping them out of the way, they work and aren't relevant...

    <img class="buttons"  src="UI/separator.gif" >
	<img class="buttons" onmouseover="mouseover(this);" onmouseout="mouseout(this);" onmousedown="mousedown(this);" onmouseup="mouseup(this);" onclick="thisForm.submit();" src="UI/save.gif" title="Saver" alt="Save" accesskey="s">
	<img class="buttons" onmouseover="mouseover(this);" onmouseout="mouseout(this);" onmousedown="mousedown(this);" onmouseup="mouseup(this);" onclick="javascript:document.ACEditor.submit();" src="UI/preview.gif" title="Preview" alt="Preview" accesskey="p">
	<img class="buttons" onmouseover="mouseover(this);" onmouseout="mouseout(this);" onmousedown="mousedown(this);" onmouseup="mouseup(this);" onclick="document.location='http://localhost/wikini/wakka.php?wiki=TestPage';" src="UI/cancel.gif" title="Cancel" alt="Cancel">

  </div><textarea onkeydown="fKeyDown()" name="body" cols="60" rows="40" wrap="soft" class="edit">

Blablabla, text to be editted is displayed here.

</textarea><br />

... Now, we have standard buttons. These ones do work, but I'd like to be able to do without them...

<input name="submit" type="submit" value="Save" accesskey="s" />
<input name="submit" type="submit" value="Preview" accesskey="p" />
<input type="button" value="Cancel" onclick="document.location='http://localhost/wikini/wakka.php?wiki=TestPage';" />
</form>
Clicking on one of the save or preview button doesn't do anything. The submit function doesn't work. Everything else works.

I just don't know why the submit() function doesn't work as intended. All the sample scripts and tutorials and documentations I found online have not helped me understanding why it's not working. The toolbar's inside the form, I've tried several alternate methods (submit(), thisForm.submit(), document.ACEditor.submit(), etc.), to no avail.

Tested it both with I.E. and Firefox.

Other question, if I do get it to work, how can I transfer values, so as to differentiate between saving and previewing?
abot1
Member
Posts: 12
Joined: Tue Sep 26, 2006 10:46 am
Contact:

Post by abot1 »

not sure but... give this a try
<input name="uniquename1" type="submit" value="Save" accesskey="s" />
<input name="uniquename2" type="submit" value="Preview" accesskey="p" onclick="javascript:document.ACEditor.submit();" />
Locked