Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tinymce interfering with my field checking

Status
Not open for further replies.

kzn

MIS
Jan 28, 2005
209
GB
Hi

The webpage is suppose to show 6 story fields one at a time, this is done using the switchid function(this works correctly).
The problem I am having is .... if i fill in story one fields say and then click on the save button instead of it coming up with an alert showing stories 2-6 need to filled in, it shows that content1 field from story one needs to be filled.... if I click on the save again... then it shows the correct error that fields 2-6 are not filled in. If I take out <script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script> then it works correctly. Any help would be appreciated, thank you

Here is my code

<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>

<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
editor_selector : "tinymce",
theme : "advanced",
plugins : "advlink,paste,",

// Theme options
theme_advanced_buttons1 : "|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,undo,redo,|,link,unlink,cleanup,code,|,forecolor",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_resizing : false,

// Example word content CSS (should be your site CSS) this one removes paragraph margins
content_css : "css/word.css",


// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// show and hide div tags
//////////////////////////////////////////////////////////////////////////////////////////////////////////

var ids=new Array('a1','a2','a3','a4','a5','a6');

function switchid(id){
hideallids();
showdiv(id);
}

function hideallids(){
//loop through the array and hide each element by id
for (var i=0;i<ids.length;i++){
hidediv(ids);
}
}

function hidediv(id) {
//safe function to hide an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'none';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'none';
}
else { // IE 4
document.all.id.style.display = 'none';
}
}
}

function showdiv(id) {
//safe function to show an element with a specified id

if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'block';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'block';
}
else { // IE 4
document.all.id.style.display = 'block';
}
}
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Check each field and report error
//////////////////////////////////////////////////////////////////////////////////////////////////////////


function validate_form() {
var myerror = new Array();
valid = true;
if(!document.getElementById("new_edition").value) {
myerror[0] = "Please fill in the Edition Date\n";
}

if(!document.getElementById("nav1_text").value) {
myerror[1] = "Please fill in Story 1 Header\n";
}

if(!document.getElementById("bubble1").value) {
myerror[2] = "Please fill in Story 1 Bubble\n";
}

if(!document.getElementById("content1").value) {
myerror[3] = "Please fill in Story 1 Content\n";
}

if(!document.getElementById("nav2_text").value) {
myerror[4] = "Please fill in Story 2 Header\n";
}

if(!document.getElementById("bubble2").value) {
myerror[5] = "Please fill in Story 2 Bubble\n";
}

if(!document.getElementById("content2").value) {
myerror[6] = "Please fill in Story 2 Content\n";
}

if(!document.getElementById("nav3_text").value) {
myerror[7] = "Please fill in Story 3 Header\n";
}

if(!document.getElementById("bubble3").value) {
myerror[8] = "Please fill in Story 3 Bubble\n";
}

if(!document.getElementById("content3").value) {
myerror[9] = "Please fill in Story 3 Content\n";
}

if(!document.getElementById("nav4_text").value) {
myerror[10] = "Please fill in Story 4 Header\n";
}

if(!document.getElementById("bubble4").value) {
myerror[11] = "Please fill in Story 4 Bubble\n";
}

if(!document.getElementById("content4").value) {
myerror[12] = "Please fill in Story 4 Content\n";
}

if(!document.getElementById("nav5_text").value) {
myerror[13] = "Please fill in Story 5 Header\n";
}

if(!document.getElementById("bubble5").value) {
myerror[14] = "Please fill in Story 5 Bubble\n";
}

if(!document.getElementById("content5").value) {
myerror[15] = "Please fill in Story 5 Content\n";
}

if(!document.getElementById("nav6_text").value) {
myerror[16] = "Please fill in Story 6 Header\n";
}

if(!document.getElementById("bubble6").value) {
myerror[17] = "Please fill in Story 6 Bubble\n";
}

if(!document.getElementById("content6").value) {
myerror[18] = "Please fill in Story 6 Content\n";
}


if(myerror.length) {

alert(myerror.join(""));
valid = false;
var myerror = "";
}
var myerror = "";
return valid;
}
</script>
<form name="myform" action="index.php" method="post" onsubmit="return validate_form();">
<p><span class="stylePinkHeader">New edition </span><span><input type="image" style="margin-left:348px; vertical-align:bottom" src="../images/Save.gif" height="25" width="88" border="0" /></span></p>
<p>New edition: <input class="formfields" type="text" name="new_edition" size="30" /><small> (example: May edition '08)</small></p>

<div>
<a href="javascript:switchid('a1');"><img src="../images/Button_story1.gif" width="88" height="25" border="0" onmouseover ="src='../images/button_overs/Button_story1_over.gif'" onmouseout="src='../images/Button_story1.gif'" /></a>
<a href="javascript:switchid('a2');"><img src="../images/Button_story2.gif" width="88" height="25" border="0" onmouseover ="src='../images/button_overs/Button_story2_over.gif'" onmouseout="src='../images/Button_story2.gif'" /></a>
<a href="javascript:switchid('a3');"><img src="../images/Button_story3.gif" width="88" height="25" border="0" onmouseover ="src='../images/button_overs/Button_story3_over.gif'" onmouseout="src='../images/Button_story3.gif'" /></a>
<a href="javascript:switchid('a4');"><img src="../images/Button_story4.gif" width="88" height="25" border="0" onmouseover ="src='../images/button_overs/Button_story4_over.gif'" onmouseout="src='../images/Button_story4.gif'" /></a>
<a href="javascript:switchid('a5');"><img src="../images/Button_story5.gif" width="88" height="25" border="0" onmouseover ="src='../images/button_overs/Button_story5_over.gif'" onmouseout="src='../images/Button_story5.gif'" /></a>
<a href="javascript:switchid('a6');"><img src="../images/Button_story6.gif" width="88" height="25" border="0" onmouseover ="src='../images/button_overs/Button_story6_over.gif'" onmouseout="src='../images/Button_story6.gif'" /></a>
</div>

<div id='a1' style="display:block;">
<table>
<tr>
<td valign="top" width="231" style="color: #3574BA;"><b>Header</b><br/ >
<input class="formfields" type="text" name="nav1_text" size="30" /><br />
<img class="storyimages" src="../images/Story1.gif" width="134" height="42" border="0" />
</td>
<td width="309" style="color: #3574BA;"><b>Bubble</b><br />
<textarea class="formfields" id="bubble1" name="bubble1" rows="5" cols="30"></textarea>
</td>
</tr>
</table>
<div style="color: #3574BA;"><b>Content</b><br />
<textarea class="formfields tinymce" name="content1" rows="30" cols="80" onblur="myform.content1.value = myform.content1.value"></textarea></div><br />
</div>

<div id='a2' style="display:none;">
<table>
<tr>
<td valign="top" width="231" style="color: #843F8F;"><b>Header</b><br/ >
<input class="formfields" type="text" name="nav2_text" size="30" /><br />
<img class="storyimages" src="../images/Story2.gif" width="134" height="42" border="0" />
</td>
<td width="309" style="color: #843F8F;"><b>Bubble</b><br />
<textarea class="formfields" name="bubble2" rows="5" cols="30"></textarea>
</td>
</tr>
</table>
<div style="color: #843F8F;"><b>Content</b><br />
<textarea class="formfields tinymce" name="content2" rows="30" cols="80"></textarea></div><br />
</div>

<div id='a3' style="display:none;">
<table>
<tr>
<td valign="top" width="231" style="color: #B2D134;"><b>Header</b><br/ >
<input class="formfields" type="text" name="nav3_text" size="30" /><br />
<img class="storyimages" src="../images/Story3.gif" width="134" height="42" border="0" />
</td>
<td width="309" style="color: #B2D134;"><b>Bubble</b><br />
<textarea class="formfields" name="bubble3" rows="5" cols="30"></textarea>
</td>
</tr>
</table>
<div style="color: #B2D134;"><b>Content</b><br />
<textarea class="formfields tinymce" name="content3" rows="30" cols="80"></textarea></div><br />
</div>

<div id='a4' style="display:none;">
<table>
<tr>
<td valign="top" width="231" style="color: #F37721;"><b>Header</b><br/ >
<input class="formfields" type="text" name="nav4_text" size="30" /><br />
<img class="storyimages" src="../images/Story4.gif" width="134" height="42" border="0" />
</td>
<td width="309" style="color: #F37721;"><b>Bubble</b><br />
<textarea class="formfields" name="bubble4" rows="5" cols="30"></textarea>
</td>
</tr>
</table>
<div style="color: #F37721;"><b>Content</b><br />
<textarea class="formfields tinymce" name="content4" rows="30" cols="80"></textarea></div><br />
</div>

<div id='a5' style="display:none;">
<table>
<tr>
<td valign="top" width="231" style="color: #D2232A;"><b>Header</b><br/ >
<input class="formfields" type="text" name="nav5_text" size="30" /><br />
<img class="storyimages" src="../images/Story5.gif" width="134" height="42" border="0" />
</td>
<td width="309" style="color: #D2232A;"><b>Bubble</b><br />
<textarea class="formfields" name="bubble5" rows="5" cols="30"></textarea>
</td>
</tr>
</table>
<div style="color: #D2232A;"><b>Content</b><br />
<textarea class="formfields tinymce" name="content5" rows="30" cols="80"></textarea></div><br />
</div>

<div id='a6' style="display:none;">
<table>
<tr>
<td valign="top" width="231" style="color: #131313;"><b>Header</b><br/ >
<input class="formfields" type="text" name="nav6_text" size="30" />
<img class="storyimages" src="../images/Story6.gif" width="134" height="42" border="0" />
</td>
<td width="309" style="color: #131313;"><b>Bubble</b><br />
<textarea class="formfields" name="bubble6" rows="5" cols="30"></textarea>
</td>
</tr>
</table>
<div style="color: #131313;"><b>Content</b><br />
<textarea class="formfields tinymce" name="content6" rows="30" cols="80"></textarea></div><br />
</div>
<input type="hidden" name="submitted" value="true" />
</form>
 
Just a hunch (I saw something similar with the FCKEditor recently on a web-app I was working on), but what happens if you click outside of the TimyMCE editor before clicking save (i.e. to blur the editor first)?

I found I had to jump through hoops to get the RTE to update its internal field as the button click was firing before the RTE blur method.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi

Just a hunch (I saw something similar with the FCKEditor recently on a web-app I was working on), but what happens if you click outside of the TimyMCE editor before clicking save (i.e. to blur the editor first)? ... no luck it even if I do this it still has the same problem. Thanks for your reply
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top