Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Очистка формы после отправки письма (https://javascript.ru/forum/misc/46525-ochistka-formy-posle-otpravki-pisma.html)

Espey 13.04.2014 22:18

Очистка формы после отправки письма
 
Здравствуйте. Вот у меня созрел вопрос, надеюсь по теме. У меня есть модуль для Joomla 1.5, он отправляет приглашение с сайта на почту. Только после отправки форма не очищается.

Можно ли после отправки письма, сделать автоматическую очистку формы?

Вот код скрипта

<?php
/**
 * @package: JLord AJAX Recommend for Joomla 1.5.
 * @subpackage: tmpl/default.php.
 * @created: October 2008.
 * @updated: 2008/11/03.
 * @copyright: Copyright (C) 2008 The Joomlord Team. All right reserved.
 * @license: GNU/GPL.
 * @author: Hoa Truong An - Joomlord Team member.
 */

// no direct access

defined('_JEXEC') or die('Restricted access');
?>

<?php if($display_title) : ?>
	<p><?php JText::printf($title);?></p>
<?php endif; ?>

<form id="form" name="myform" action="<?php echo $path; ?>modules/mod_jlord_recommend/jlord_recommend_underground.php" method="post">
	
	<div style="border:0;">
		<p class="jlord-recommend-title"><?php echo JText::_('Your name'); ?></p>
		<input type="text" name="your_name" id="your_name" class="inputbox"/>
		<p class="jlord-recommend-title"><?php echo JText::_('Your e-mail'); ?></p>
		<input type="text" name="your_email" id="your_email" class="inputbox"/>
		
		<p class="jlord-recommend-title">
			<?php echo JText::_('Your Friend\'s Email'); ?>&nbsp;
		</p>
						
		<input type="text" name="friend_email[0]" id="friend_email_0" class="inputbox" /> <p/>
		<div style="border:0;" id="friend_email_tab">
		</div>
	</div>
	
	<?php if($displaymsg==1): ?>
	<!-- show/hide message -->
	<p id="jlord-recommend-message"><?php echo JText::_('Message'); ?>&nbsp;<a onclick="showMessageForm();" href="javascript:void(0)" title="<?php echo JText::_('click here to show message box'); ?>">[+]</a></p>
	<!-- end show/hide message -->
	<?php endif; ?>
	<!-- end basic form -->
	
	<!--<table id="insertRow">
		<tr>
			<td align="right"><a onclick="remRow()" href="javascript: void(0)">[-]</a></td>
			<td align="right"><a onclick="addRow()" href="javascript: void(0)">[+]</a></td>
		</tr>
	</table>-->
	
	
	<div style="clear:both;">
	<p></p>
		<input type="submit"; class="button" name="submit" value="<?php JText::printf($send); ?>" />
	</div>
	<input type="hidden" name="successful" value ="<?php JText::printf($successful); ?>" />
	<input type="hidden" name="site" value ="<?php JText::printf($site); ?>" />
	<input type="hidden" name="success" value ="<?php JText::printf($successful); ?>" />
	<input type="hidden" name="subject" value ="<?php JText::printf($subject_mail); ?>" />
	<input type="hidden" name="content" value ='<?php JText::printf($content_mail); ?>' />
	<input type="hidden" name="errormail" value ="<?php JText::printf($error_mail); ?>" />
	<input type="hidden" name="host" value ="<?php JText::printf($host); ?>" />
	<input type="hidden" name="message_default" value ="<?php JText::printf($message_default); ?>" />
	<input type="hidden" name="site_url" value ="<?php JText::printf($site_url); ?>" />
	<div id="form_box">
	<div id="jlord-recommend-display-error" class ="jlord-recommend-display-error" align="center" ></div>
	
	<div id="log">
		<div id="log_res" class="jlord-recommend-display-error"><!-- spanner --></div>
	</div>

</div>
</form>

ksa 14.04.2014 09:49

Цитата:

Сообщение от Espey
Можно ли после отправки письма, сделать автоматическую очистку формы?

Как вариант...

<!DOCTYPE html>
<html>
<head>
<!--
<script src='http://code.jquery.com/jquery-latest.js'></script>
<link rel='stylesheet type=text/css href=tmp.css' />
-->
<style type='text/css'>
</style>
<script type='text/javascript'>
function send(Obj){
	// Отправка формы
	Obj.parentNode.reset();
};
</script>
</head>
<body>
<form>
	<div>
		<input type='text' />
		<input type='checkbox' />
		<input type='radio' name='test' />
		<input type='radio' name='test' />
	</div>
	<input type='reset' value='Reset' />
	<input type='button' value='Send' onclick='send(this);' />
</form>
</body>
</html>

Espey 14.04.2014 22:51

Это нужно нажимать, а я думал авто очистка.

danik.js 15.04.2014 00:47

Цитата:

Сообщение от Espey
Это нужно нажимать

То есть твоя форма без нажатия отправляется? Усилием мысли?


Часовой пояс GMT +3, время: 01:22.