gpt4 book ai didi

javascript - 让按钮填写联系表格的一部分

转载 作者:行者123 更新时间:2023-12-03 04:18:21 25 4
gpt4 key购买 nike

我在我提供的 SEO 服务下方放置了一个按钮,当他们单击该按钮时,我希望它能够将他们引导到下面的联系表单,并将“需要的服务”区域填写为“SEO”。这可能吗?

<!-- MY FORM THAT I WANT FILLED OUT AFTER THEY CLICK A BUTTON -->

<form id="contact-form" class="form" action="contact.php" method="POST" role="form">
<div class="form-group">
<label class="form-label" for="name"></label>
<input type="text" class="form-control" id="name" name="name" placeholder="Your Name" tabindex="1" required>
</div>
<div class="form-group">
<label class="form-label" for="email"></label>
<input type="email" class="form-control" id="email" name="email" data-constraints="@NotEmpty @Email" placeholder="Your Email" tabindex="2" required>
</div>
<div class="form-group">
<label class="form-label" for="subject"></label>
<input type="text" class="form-control" id="subject" name="subject" placeholder="Service Needed" tabindex="3">
</div>
<div class="form-group">
<label class="form-label" for="comments"></label>
<textarea rows="5" cols="50" name="comments" class="form-control" id="comments" placeholder="Message..." tabindex="4" required></textarea>
</div>
<div class="text-center">
<button type="submit" value="send" class="btn btn-start-order">Send Message</button>
</div>
</form>



<!-- BUTTON I USE -->
<a href="index.html#contact" class="btn btn-default">get a quote</a>

最佳答案

$.ready(function(){
$('#myButtonID').click(function(){
$('#subject').val('SEO');
event.preventDefault(); // prevent default anchor tag action otherwise animation wont work
$('html, body').animate({scrollTop: $('#contact-form').offset().top}, 300 /*duration*/);
return false;
});

});

关于javascript - 让按钮填写联系表格的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44054702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com