Skip to content

Instantly share code, notes, and snippets.

@freetitelu
Last active August 29, 2015 14:27
Show Gist options
  • Save freetitelu/c0da6444f313067c0e6f to your computer and use it in GitHub Desktop.
Save freetitelu/c0da6444f313067c0e6f to your computer and use it in GitHub Desktop.
//input "checkbox.value" from checked checkbox in textarea.value on.click //Вставка текстов из активированных checkbox в textarea при их активации
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<form class="mailForm" id="bigMailForm" action="mail.php" method="post" enctype="multipart/form-data">
<div class="_row" style="display: none">
<select class="_width" name="title">
<option selected="selected">Help me</option>
</select>
</div>
<div class="_row">
<input class="_width" type="text" name="name" placeholder="Your name">
</div>
<div class="_row">
<input class="_width" type="tel" name="tel" pattern="^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$" required="" placeholder="Your phone:* +7 XXX XXX XX XX">
</div>
<div class="mailForm_checkboxes">
<div class="_row">
<input class="mailForm_checkbox mail_option _width" type="checkbox" name="option1" value="One"><div class="checkbox_title">One</div>
</div>
<div class="_row">
<input class="mailForm_checkbox mail_option _width" type="checkbox" name="option2" value="Two"><div class="checkbox_title">Two</div>
</div>
<div class="_row">
<input class="mailForm_checkbox mail_option _width" type="checkbox" name="option3" value="Three"><div class="checkbox_title">Three</div>
</div>
<div class="_row">
<input id="laminat" class="mailForm_checkbox mail_option _width" type="checkbox" name="option4" value="Fourth"><div class="checkbox_title">Fourth</div>
</div>
</div>
<div class="_row">
<textarea id="textCallback" class="_width" rows="3" name="mess" placeholder="Your question"></textarea>
</div>
<div class="_row">
<input class="_width" type="hidden" name="valTrFal" value="valTrFal_disabled">
<label class="_width" for="checkBoxId">I'm not bot*</label>
<input id="chechboxCapcha" class="mailForm_capcha mailForm_checkbox _width" type="checkbox">
</div>
<div class="_row">
<span class="_width">*you should do it</span>
<input class="_width button1" style="background: #a71606" type="submit" value="Sale me" disabled="disabled" name="submit">
</div>
</form>
<script>
$(".mail_option").on("click", function(){
var textCallback = $('#textCallback');
textCallback.empty();
var mailOptionChecked = $('.mail_option:checked');
mailOptionChecked.each(function(){
textCallback.append(
$(this).val() + "\n"
);
var optionValue = $(this).val();
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment