1 Replies - 6881 Views - Last Post: 20 August 2009 - 04:47 AM

#1 NARKOZ  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 09-September 08

onClick="form.submit(); doesn't work on IE & Opera

Posted 19 August 2009 - 07:29 PM

Hi. I have a code (see below), in Firefox it works perfectly: it saves submitted information after clicking __JL_SAVE button and keeps user on same page.
But in Internet Explorer & Opera it only redirects to index page (index.php) and doesn't save submitted information. What can I do for solving this problem? Thanks.

Here is code:

	echo '<form action="index.php" id="mosForm" method="post" enctype="multipart/form-data">';
		global $mainframe;
		
//		echo "<pre>".print_r($mainframe->_session,true)."</pre>";
//		echo "<pre>".print_r($session,true)."</pre>";
		$tabs = new mosTabs( 1 );
		$tabs->startPane( 'myinfo' );
		$tabs->startTab( __JL_MAIN, "jl_first");

			?>

	<fieldset>
		<legend><?=__JL_ABOUT_MYSELF?></legend>
		<span class="a" onclick="showHideLegend('about_myself_1')"><?=__JL_EDIT_BLOCK;?></span>
		<div id="about_myself_descr" style="display: block"><?=__JL_SELF_DESCR;?></div>
		<div id="about_myself_1" style="display: none"><?php include "html/about_myself_fill.php"?></div>
		<div id="about_myself_2""><?php include "html/about_myself_show.php"?></div>
	</fieldset>

	<fieldset>
		<legend><?=__JL_ABOUT_MYSELF?></legend>
		<span class="a" onclick="showHideLegend('type_1')"><?=__JL_EDIT_BLOCK;?></span>
		<?php if ($typ_block) {?>
			<?php /* <input type="checkbox" id="jl_type_block" name="jl_type_block" <?php if ($roon_type_block) echo 'checked ';?> /> */ ?>
			<input type="checkbox" id="jl_type_block" name="jl_type_block" disabled <?php  echo 'checked ';?> />
			<label for="jl_type_block"><?=__JL_ON_BLOCK?></label>
		<?php } else {
			echo __JL_OFF_BLOCK;
		}?>

		<div id="about_myself_descr" style="display: block"><?=__JL_SELF_DESCR;?></div>

		<div id="type_1" style="display : none">
			<?php include "html/type.php"?>
		</div>
		<?php if ($typ_block) { ?>
			<div id="type_2">
				<?php include "html/type_show.php"?>
			</div>
		<?php } ?>
		</fieldset>

		<fieldset>
			<legend><?=__JL_INTEREST?></legend>
			<span class="a" onclick="showHideLegend('interest_1')"><?=__JL_EDIT_BLOCK;?></span>
			<?php if ($interest_block) {?>
				<input type="checkbox" id="jl_interest_block" name="jl_interest_block" disabled <?php echo 'checked ';?> />
				<label for="jl_interest_block"><?=__JL_ON_BLOCK?></label>
			<?php } else
				echo __JL_OFF_BLOCK;
			?>
			<div id="interest_descr" style="display:block"><?=__JL_INTEREST_DESCR;?></div>
			<div id="interest_1" style="display:none">
				<?php include "html/interest.php"?>
			</div>
			<?php if ($interest_block) { ?>
				<div id="interest_2">
				<?php include "html/interest_show.php"?>
				</div>
			<?php } ?>
		</fieldset>
	
		<fieldset>
			<legend><?php echo "Знакомства"; ?></legend>
			<span class="a" onclick="showHideLegend('acquaintance_1')"><?=__JL_EDIT_BLOCK;?></span>
			<?php if ($acquaintance_block) {?>
				<input type="checkbox" id="jl_acquaintance_block" name="jl_acquaintance_block" disabled <?php echo 'checked ';?> />
				<label for="jl_acquaintance_block"><?=__JL_ON_BLOCK?></label>
			<?php } else
				echo __JL_OFF_BLOCK;
			?>
			<div id="acquaintance_descr" style="display:block"><?php echo "Найди половинку";?></div>
			<div id="acquaintance_1" style="display:none">
				<?php include "html/acquaintance_fill.php"?>
			</div>
			<?php if ($acquaintance_block) { ?>
				<div id="acquaintance_2">
				<?php include "html/acquaintance_show.php"?>
				</div>
			<?php } ?>
		</fieldset>
	
		 <?php

	/* $tabs->endTab();

	$tabs->startTab( __JL_PORTRAIT, "jl_second");
			echo '<div id="avtoportrait">';
	if ($row->percent_portrait==0)  { echo '<div align="right" style="padding: 5px 20px 5px 0;">' . __JL_OFF_BLOCK . '</div>'; }
			  include "html/avtoportrait.php";
			echo '</div>';*/

	$tabs->endTab();
	$tabs->startTab( __JL_PHOTO, "jl_third");
	echo '<div id="photo">';
	$photos = Joomlove::getImage($row->user_id, 1);
	HTML_joomlove::photo($photos,0);
	if (isset($photos['not']) && count($photos['not'])) {
		echo '<fieldset>';
		HTML_joomlove::photo_not($photos['not']);
		echo '</fieldset>';
	}
	echo '</div>';
	$tabs->endTab();

	// Страны
	$tabs->startTab( __JL_COUNTRYES, "jl_countries");

	echo "<p align=\"right\">";
	$row->ud_countryes_was = (!empty($row->ud_countryes_was)) ? unserialize($row->ud_countryes_was) : "";
//	$checked = ( $row->ud_countryes_was['on'] == "on") ? "checked" : "";
	$checked = "checked";
	echo  "<input type=\"checkbox\" id=\"jl_countries_block\" name=\"jl_countries_block\" $checked disabled />";
	echo  "<label for=\"jl_countries_block\">Включить блок</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<br/>
	<!--<input type=\"submit\" name=\"save\" value=\"" . __JL_SAVE ."\" onclick=\"mosForm.submit()\" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
	";
	echo  "</p>";


	 $query="SELECT * FROM `#__joomlove_countries`";
	 $database->setQuery($query);
	 $countries_list = $database->loadAssocList('country_id');
	// Заполняем список стран
	 $an_rows = $database->loadObjectList();

	echo '<fieldset>';
	echo "<legend>".__JL_COUNTRYES_WAS."</legend>";
	include ('html/country_edit.php');
	echo $country_html;
	echo "<div id=\"debug\" style=\"padding:3px;\"></div>";
	echo '</fieldset>';

	echo '<fieldset>';
	echo "<legend>".__JL_COUNTRYES_WAS_ADD."</legend>";

	 $countryes = "";
	 $i = 1;
	 echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tbody><tr>";
	 foreach ($an_rows as $an_row) {
		$checked = "";
		if (!empty($row->ud_countryes_was)){
			foreach($row->ud_countryes_was as $country_was ){
				if ($country_was == $an_row->country_id) $checked = "checked";
			}

		} // if (!empty($row->ud_countryes_was)){

		echo "<td><label><input type=\"checkbox\" id=\"an_id\" name=\"country_was_".$an_row->country_id."\" value=\"".$an_row->country_id."\" $checked />".$an_row->country."</label></td>";
		$i++;
		if ($i == 4) {
			echo "</tr><tr>";
			$i = 1;
			$k++;
		}
	  }
	  for ($i; $i < 4; $i++) echo "<td>&nbsp;</td>";
	  echo "</tr></tbody></table><p>".__JL_COUNTRYES_WAS_DESCR."</p>";
	echo '</fieldset>';
	$tabs->endTab();

	// Путешествия
	$tabs->startTab( __JL_CRUISES, "jl_cruise");
	require_once("includes/alex.class.php");
	 echo "<h4>".__JL_CRUISES_PLAN."</h4>"; 

	 ?>
	 <div style="float: right">
			 <?php
	$checked = ( $row->ud_travel_block_on == 1) ? "checked" : "";
	$checked = "checked";
	?>
			  <input type="checkbox" id="jl_travel_block" name="jl_travel_block" disabled <?php echo $checked ?>  />
			  <label for="jl_travel_block">Включить блок</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		   </div>

	<br style="clear:both"/>
	<p>
	<?php

	// *****************************
	// Added. List of all my travels
	// *****************************
	$query = "SELECT * FROM #__joomlove_travel_plane tp "
	."\n LEFT JOIN #__joomlove_countries tpc ON tpc.country_id=tp.tp_country"
	."\n WHERE tp.tp_uid = '".$row->user_id."'";

	$database->setQuery( $query );
	$travels = $database->loadObjectList();

	echo "<fieldset>";
	echo "<legend>".__JL_MY_CRUISES."</legend>";
	global $_JL_CRUISES_COTRAVELERS;
	echo "<table cellspacing=\"0\" cellspadding=\"2\" width=\"100%\">\n";
	echo "<tr>\n";

	echo "<td><strong>".__JL_CRUISES_NEED_COTRAVELER."</strong></td>\n";
	echo "<td><strong>".__JL_CRUISES_BEGIN_DATE."</strong></td>\n";
	echo "<td><strong>".__JL_CRUISES_HOW_LONG."</strong></td>\n";
	echo "<td><strong>".__JL_CRUISES_COUNTRY."</strong></td>\n";
	echo "<td><strong>".__JL_CRUISES_DESCR2."</strong></td>\n";
	echo "<td><strong>&nbsp;</strong></td>\n";
	echo "</tr>\n";
	
	$link_mt = sefRelToAbs('index.php?option=com_joomlove&task=markTravel');
	?>
	<script type="text/javascript">
		function markTravel(tid) {
			confirmtxt = 	"Вы действительно желаете выделить данное путешествие в календаре? \n" +
							"С вашего счета будет списано <?=$jlConfig_feature_travel?> $ " + 
							"(сейчас на счету <?=$jl_my_balance?>$) ";
							
			if (confirm(confirmtxt)) {
				$jq.blockUI({message: '<h3>Подождите.</h3> <h3>Идет обработка</h3>', fadeIn: 700, fadeOut: 700, showOverlay: true});
				$jq.post('<?=$link_mt?>',{
					tid: tid
						},function(data){
							if (data.result == 'OK') {
								$jq('#myballance').html(data.ballance);
								$jq('#tprow_' + tid).css('background','#FFC8A1');
								$jq('#tUpLink_' + tid).html('');
							} else {
								alert('Ошибка при получении данных от сервера. попробуйте позже.');
							}
							$jq.unblockUI();
	//						alert(data);
				},"json");
			}
		}
	</script>
	<?php

	foreach ($travels as $travel) {
	if ($travel->tp_featured == 1) {
		echo "<tr style='background:#FFC8A1;'>\n";
	} else {
		echo "<tr id='tprow_{$travel->tp_id}'>\n";
	}
		

	$date = date("d-m-Y", $travel->tp_begin_date);
	$dateBegin = explode("-", $date);
	$dateBegin[1] = $_JL_MONTH[(int)$dateBegin[1]];
	$beginDate =  $dateBegin[0]." ".$dateBegin[1]." ".$dateBegin[2];

	if ($travel->tp_begin_date <= $travel->tp_end_date) $dateDiff = anDATE::calcPeriod ($travel->tp_begin_date, $travel->tp_end_date);
	else $dateDiff = anDATE::calcPeriod ($travel->tp_end_date, $travel->tp_begin_date);
	if ($dateDiff[3] > 0) $howLong = $dateDiff[3]." ".__JL_CRUISES_DAYS;
	if ($dateDiff[4] > 0) $howLong = $dateDiff[4]." ".__JL_CRUISES_MONTHS;
	if ($dateDiff[5] > 0) $howLong = $dateDiff[5]." ".__JL_CRUISES_YEARS;

	if (isset($travel->tp_country)) $cruisesCountry =  $travel->country;
	else $cruisesCountry = "&nbsp;";

		$cruisesCoTravelers = "";
	$tmp = false;
	$travel->tp_co_traveler = explode("|",$travel->tp_co_traveler);
	if (is_array($travel->tp_co_traveler)){
	foreach ($travel->tp_co_traveler as $key=>$value){
	 	if ($tmp) $cruisesCoTravelers .=  ", ";
	else $tmp = true;
	$_JL_CRUISES_COTRAVELERS[$value] = "Не важно";
	$cruisesCoTravelers .=  "&nbsp;&nbsp;".$_JL_CRUISES_COTRAVELERS[$value];
	}
	}else{
	$cruisesCoTravelers .=  "&nbsp;&nbsp;".$_JL_CRUISES_COTRAVELERS[$travel->tp_co_traveler];
	}

	echo "<td>".$cruisesCoTravelers."</td>\n";
	echo "<td>".$beginDate."</td>\n";
	echo "<td>".$howLong."</td>\n";
	echo "<td>".$cruisesCountry."</td>\n";
	echo "<td>".$travel->tp_descr."</td>\n";

	$link = sefRelToAbs( 'index.php?option=com_joomlove&amp;task=delMT&amp;tid='. $travel->tp_id );
	$link_e = sefRelToAbs( 'index.php?option=com_joomlove&amp;task=edittrav&amp;tid='. $travel->tp_id );
	echo "<td><a href=\"$link_e\">редакт.</a> <a href=\"$link\">".__JL_DEL."</a>";

	if ($travel->tp_featured != 1) {
		if ($jl_my_balance >= $jlConfig_feature_travel ) {
			HTML_JoomLove::spanLikeLink("выделить", "id = 'tUpLink_{$travel->tp_id}' onclick = 'markTravel({$travel->tp_id})' title='Выделяет ваше путешествие в календаре! Стоимость: ".$jlConfig_feature_travel."$' class='bslink'");
		} else {
			HTML_JoomLove::spanLikeInactiveLink("выделить", "title='Выделяет ваше путешествие в календаре. У вас недостаточно средств на счете! Стоимость услуги: ".$jlConfig_feature_travel."$' class='bslink'");
		}
	}
	echo "</td>\n";
	echo "</tr>\n";
	// ***************************************************
	// ******************* попутчики *********************
	// ***************************************************
	echo "<tr>\n";
	echo "<td colspan=\"6\">К вам записались: \n";

	$query = "SELECT * FROM #__joomlove_travel_companions tc"
			."\n LEFT JOIN #__joomlove_users ju ON ju.user_id=tc.uid"
			."\n LEFT JOIN #__users u ON u.id=ju.system_id"
			."\n WHERE tid=".$travel->tp_id . " AND moder_result<2";
	$database->setQuery($query);
	$travel_companions = $database->loadObjectList();

	foreach ($travel_companions as $travel_companion) {
		$link_user_profile = sefRelToAbs( 'index.php?option=com_joomlove&amp;task=showUser&amp;username=').$travel_companion->username;
		
		if ($travel_companion->moder_result == 0) {
			$l_a			= sefRelToAbs( 'index.php?option=com_joomlove&amp;task=acceptcompanion&amp;tid='.$travel->tp_id.'&amp;uid='.$travel_companion->user_id);
			$link_allow 	= "<b><a style='color:green' href='$l_a' title='Одобрить кандидатуру'>[+]</a></b>";
		} else {
			$link_allow 	= "";
		}
		$l_d				= sefRelToAbs( 'index.php?option=com_joomlove&amp;task=declinecompanion&amp;tid='.$travel->tp_id.'&amp;uid='.$travel_companion->user_id);
		$link_decline 		= "<b><a style='color:red' href='$l_d' title='Отклонить кандидатуру'>[-]</a></b>";
		
		
		
		echo " <a href=\"$link_user_profile\">".$travel_companion->name ."</a> $link_allow $link_decline";
	}

	echo "</td>\n";	
	echo "</tr>\n";
	// ****************  *****************	
	
	if ($travel->tp_descr2 != '') {
		echo "<tr>\n";
		echo "<td colspan=\"6\"><b>Впечатления от поездки:</b><br/>".$travel->tp_descr2."</td>\n";
		echo "</tr>\n";
	}


	echo "<tr>\n";
	echo "<td colspan=\"6\"><hr></td>\n";
	echo "</tr>\n";
	}

	echo "</table>";
	echo "</fieldset>";

	//********************************
	// End of add
	//********************************

	?>
	</p>

			 <fieldset>
				<legend><?=__JL_ADD_CRUISE?></legend>
		   <?php
				$val = ( isset($row->tp_id) && isset($row->tp_uid) && ($row->tp_uid = $row->user_id) ) ? "update" : "new";
				echo "<input name=\"jl_travel_plane_1\" type=\"hidden\" value=\"$val\" />";
	 		echo HTML_joomlove::showCruiseForm($row);
	?>
	 </fieldset>
		<?php
	$tabs->endTab();

	// Встречи
	$tabs->startTab( __JL_MEET, "jl_meet");
	 require_once("includes/alex.class.php");
	 echo "<h4>".__JL_MEET_PLAN."</h4>"; ?>
	 <p align="right">
			 <?php
		$checked = ( $row->ud_meet_block_on == 1) ? "checked" : "";
	?>
			  <input type="checkbox" id="jl_meet_block" name="jl_meet_block" <?php echo $checked ?>  />
			  <label for="jl_meet_block">Включить блок</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		   </p>
	 <p>
	<?php
	// *****************************
	// Added. List of all my meets
	// *****************************
	$query = "SELECT * FROM #__joomlove_meets m"
		."\n LEFT JOIN #__joomlove_countries mc ON mc.country_id=m.m_country"
		."\n WHERE m_uid = '".$row->user_id."'";

	$database->setQuery( $query );
	$meets = $database->loadObjectList();

	echo "<fieldset>";
	echo "<legend>".__JL_MEET."</legend>";
	global $_JL_MEET_DAY_PART;
	echo "<table cellspacing=\"0\" cellspadding=\"2\" width=\"100%\">\n";
	echo "<tr>\n";

	echo "<td><strong>".__JL_MEET_NEED."</strong></td>\n";
	echo "<td><strong>".__JL_MEET_DATE."</strong></td>\n";
	echo "<td><strong>".__JL_MEET_TIME."</strong></td>\n";
	echo "<td><strong>".__JL_MEET_COUNTRY."</strong></td>\n";
	echo "<td><strong>".__JL_MEET_CITY."</strong></td>\n";
	echo "<td><strong>".__JL_MEET_PLACE."</strong></td>\n";
	echo "<td><strong>".__JL_MEET_DESCR."</strong></td>\n";
	echo "<td><strong>&nbsp;</strong></td>\n";
	echo "</tr>\n";


	foreach ($meets as $meet) {

	echo "<tr>\n";

	$date = date("d-m-Y", $meet->m_date);
	$dateBegin = explode("-", $date);
	$dateBegin[1] = $_JL_MONTH[(int)$dateBegin[1]];
	$beginDate =  $dateBegin[0]." ".$dateBegin[1]." ".$dateBegin[2];

	$meetsCoTravelers = "";
	$tmp = false;
	$meet->m_with = explode("|",$meet->m_with);
	if (is_array($meet->m_with)){
		foreach ($meet->m_with as $key=>$value){
			  if ($tmp) $meetsCoTravelers .=  ", ";
			else $tmp = true;
			$meetsCoTravelers .=  "&nbsp;&nbsp;".$_JL_CRUISES_COTRAVELERS[$value];
		}
	}else{
		$meetsCoTravelers .=  "&nbsp;&nbsp;".$_JL_CRUISES_COTRAVELERS[$meet->m_with];
	}

				$dayPart1 = "";

	if (isset($meet->m_dayPart)){
		$tmp = false;
		$meet->m_dayPart = explode("|",$meet->m_dayPart);
		if (is_array($meet->m_dayPart)){
			foreach ($meet->m_dayPart as $key=>$value){
				  if ($tmp) $dayPart1 .=  ", ";
				else $tmp = true;
				if ($value <= 0) $dayPart1 .=  "Всех";
				else $dayPart1 .=  "&nbsp;&nbsp;".$_JL_MEET_DAY_PART[$value];
			}
		}else{
			$dayPart1 .= "&nbsp;&nbsp;".$_JL_MEET_DAY_PART[$meet->m_dayPart];
		}

	}

	$meetCountry 	= $meet->country;
	$meetCity 		= $meet->m_city;
	$meetPlace 		= $meet->m_place;
				$meetDescr 		= $meet->m_info;

	echo "<td>".$meetsCoTravelers."</td>\n";
	echo "<td>".$beginDate."</td>\n";
	echo "<td>".$dayPart1."</td>\n";
	echo "<td>".$meetCountry."</td>\n";
	echo "<td>".$meetCity."</td>\n";
	echo "<td>".$meetPlace."</td>\n";
	echo "<td>".$meetDescr."</td>\n";

	$link = sefRelToAbs( 'index.php?option=com_joomlove&amp;task=delMT&amp;tid='. $meet->m_id .'&amp;mode=meet' );
	echo "<td><a href=\"$link\">".__JL_DEL."</a></td>\n";
	echo "</tr>\n";
	echo "<tr>\n";
	echo "<td colspan=\"8\"><hr></td>\n";
	echo "</tr>\n";
	}

	echo "</table>";
	echo "</fieldset>";

	//********************************
	// End of add
	//********************************
	?>
	 </p>
		   <fieldset>
		   <legend><?=__JL_MEET?></legend>
		   <?php

	//		$val = ( isset($row->m_id) && isset($row->m_uid) && ($row->m_uid = $row->user_id) ) ? "update" : "new";
	echo "<input name=\"jl_meet_1\" type=\"hidden\" value=\"new\" />";
	echo HTML_joomlove::showMeetForm($row);
	?>
	 </fieldset>
		 <?php
	require_once($GLOBALS['mosConfig_absolute_path']."/components/com_joomlove/joomlove.comments.php");
	   		$comm = jl_Comment::getCommentsByObj("meet", $row->user_id, 2);

	if ($comm){
	echo "<strong>".__JL_COMMENTS."</strong>:<br />";
	//echo "<fieldset style=\"width:580px%\"><legend>".__JL_COMMENTS."</legend>";
			echo $comm;
	echo '<input type="hidden" id="jl_com_comment" name="jl_com_comment" value="" />
		  <input name="jl_com_act" type="hidden" value="edit" />
		  <input name="jl_com_obj" type="hidden" value="meet" />
		  <input name="jl_com_obj_id" type="hidden" value="" />
		  <input name="jl_com_uid" type="hidden" value="" />
		  <input name="jl_com_id" type="hidden" value="" />
		  <input name="jl_com_sess" type="hidden" value="" />';
	 		//echo "</fieldset>";
	}
	?>
		<?php
	$tabs->endTab();
	/********************************************/
	/************* GUEST BOOK *******************/
	/********************************************/
	$tabs->startTab("<span title='guestbook' class='bslink' style='color:green'>book</span>", "jl_guestbook");	
	HTML_joomlove::showgb('my');
	$tabs->endTab();

	/********************************************/
	/***************** BLOG *********************/
	/********************************************/
	$tabs->startTab("<span title='Your mini blog' class='bslink' style='color:green;'>Posts</span>", "jl_blog");	
	HTML_JoomLove::showblog('my');
	$tabs->endTab();

	
	$tabs->endPane();
	echo '<br style="clear:both" />';	
			echo '<input type="submit" name="save" value="' . __JL_SAVE .'" onclick="mosForm.submit();" />';
			echo '<input type="hidden" name="option" value="com_joomlove" />';
			echo '<input type="hidden" id="task" name="task" value="save_info" />';
			echo '</form>';
 


Full source available here: http://narkoz.pastebin.com/f4f036f5

This post has been edited by NARKOZ: 19 August 2009 - 07:42 PM


Is This A Good Question/Topic? 0
  • +

Replies To: onClick="form.submit(); doesn't work on IE & Opera

#2 roudard  Icon User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 143
  • Joined: 26-September 05

Re: onClick="form.submit(); doesn't work on IE & Opera

Posted 20 August 2009 - 04:47 AM

hey,

the parsing is all weird, it's hard to see ...

if that is the submit button :
   <input type=\"submit\" name=\"save\" value=\"" . __JL_SAVE ."\" onclick=\"mosForm.submit()\" />  

mosForm is not defined in this scope (at least i can't find the definition anywhere), replace it by document.getElementById('mosForm').submit();

that should do the trick ...

hope this helps
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1