Comment est-ce que je ferais ceci quand l'utilisateur clique sur un paquet qu'il glisse à l'étape suivante? Au lieu d'avoir à cliquer sur le bouton en bas. Aussi, existe-t-il un moyen de savoir quel paquet ils ont sélectionné?Slider forme question
Voici un lien pour le moment.
http://www.prototypesyndicate.com/_forms/marketing_packages.html
est Ci-dessous le code html
<div id="wrapper">
<div id="steps">
<form id="formElem" name="formElem" action="../send_marketing.php" method="post">
<fieldset class="step">
<legend>Select a Marketing Package</legend>
<!--**************************** PACKAGES ****************************-->
<div class="grid" id="griddler_ii">
<div class="sections col3">
<div>
<article class="first">
<header>
<hgroup class="plan"><h1>Student</h1></hgroup>
<hgroup class="price"><h2>$10<em>Monthly</em></h2></hgroup>
</header>
<section>
<ul>
<li>$20</li>
<li>4.0%</li>
<li>400</li>
<li>100MB</li>
<li>500GB</li>
<li> </li>
</ul>
</section>
<footer>
<a class="button" href="#"><span>Choose Plan</span></a></li>
</footer>
</article>
<article class="selected">
<header>
<hgroup class="plan"><h1>Professional</h1></hgroup>
<hgroup class="price"><h2>$20<em>Monthly</em></h2><h4 class="label">Best value</h4></hgroup>
</header>
<section>
<ul>
<li>Waived</li>
<li>3.0%</li>
<li class="tooltip-holder">1000
<div class="tooltip">
<div>
<h3>Available Space</h3>
<p>Duis volutpat nisl ac ante pulvinar non lobortis urna adipiscing. In hac habitasse platea dictumst. </p>
</div>
</div></li>
<li class="tooltip-holder">400MB
<div class="tooltip">
<div>
<h3>Available Space</h3>
<p>Duis volutpat nisl ac ante pulvinar non lobortis urna adipiscing. In hac habitasse platea dictumst. </p>
</div>
</div></li>
<li class="tooltip-holder">1000
<div class="tooltip">
<div>
<h3>Available Space</h3>
<p>Duis volutpat nisl ac ante pulvinar non lobortis urna adipiscing. In hac habitasse platea dictumst. </p>
</div>
</div>
</li>
<li><span class="check">Yes</span></li>
</ul>
</section>
<footer>
<a class="button" href="#"><span>Choose Plan</span></a>
</footer>
</article>
<article class="last">
<header>
<hgroup class="plan"><h1>Premium</h1></hgroup>
<hgroup class="price"><h2>$40<em>Monthly</em></h2></hgroup>
</header>
<section>
<ul>
<li>Waived</li>
<li>1.0%</li>
<li>Unlimited</li>
<li>10GB</li>
<li>Unlimited</li>
<li><span class="check">Yes</span></li>
</ul>
</section>
<footer>
<a class="button" href="#"><span>Choose Plan</span></a>
</footer>
</article>
</div>
</div>
</div>
<!--[if IE 8]>
<script type="text/javascript">
$("#griddler_ii section ul li:nth-child(even)").addClass("even");
</script>
<![endif]-->
<!--**************************** PACKAGES: END ****************************-->
</fieldset>
<fieldset class="step">
<legend class="tight">Provide Your Contact Information</legend>
<p class="column2">
<label for="updates">Tell Us About Yourself?<br>(Your industry, about your customers, where you are based)</label>
<textarea name="description" rows="7" cols="20"></textarea>
</p>
<p>
<label for="name">Name*:</label>
<input id="name" name="name" type="text" AUTOCOMPLETE=OFF class="required" />
</p>
<p>
<label for="company">Company:</label>
<input id="company" name="company" type="text" AUTOCOMPLETE=OFF />
</p>
<p>
<label for="website">Email*:</label>
<input id="website" name="email" placeholder="e.g. [email protected]" type="text" AUTOCOMPLETE=OFF class="required" />
</p>
<p>
<label for="website">Website:</label>
<input id="website" name="website" type="text" AUTOCOMPLETE=ON />
</p>
<p>
<label for="phone">Phone*:</label>
<input id="phone" name="phone" placeholder="e.g. +351215555555" type="tel" AUTOCOMPLETE=OFF class="required" />
</p>
</fieldset>
<fieldset class="step">
<br/><br/><br/><br/>
<p class="review">
If all required fields in the form are correctly filled a green checkmark will appear. A red checkmark indicates that some required field is missing or filled out with invalid data.
</p>
<p class="submit">
<button id="registerButton" type="submit">Let’s Begin</button>
</p>
</fieldset>
</form>
</div>
<div id="navigation" style="display:none;">
<ul>
<li>
<a href="#">Select a Packages</a>
</li>
<li>
<a href="#">Provide your Contact</a>
</li>
<li>
<a href="#">Let's Begin</a>
</li>
</ul>
</div>
</div>
JAVASCRIPT CI-DESSOUS
$(function() {
/*
number of fieldsets
*/
var fieldsetCount = $('#formElem').children().length;
/*
current position of fieldset/navigation link
*/
var current = 1;
/*
sum and save the widths of each one of the fieldsets
set the final sum as the total width of the steps element
*/
var stepsWidth = 0;
var widths = new Array();
$('#steps .step').each(function(i){
var $step = $(this);
widths[i] = stepsWidth;
stepsWidth += $step.width();
});
$('#steps').width(stepsWidth);
/*
to avoid problems in IE, focus the first input of the form
*/
$('#formElem').children(':first').find(':input:first').focus();
/*
show the navigation bar
*/
$('#navigation').show();
/*
when clicking on a navigation link
the form slides to the corresponding fieldset
*/
$('#navigation a').bind('click',function(e){
var $this = $(this);
var prev = current;
$this.closest('ul').find('li').removeClass('selected');
$this.parent().addClass('selected');
/*
we store the position of the link
in the current variable
*/
current = $this.parent().index() + 1;
/*
animate/slide to the next or to the corresponding
fieldset. The order of the links in the navigation
is the order of the fieldsets.
Also, after sliding, we trigger the focus on the first
input element of the new fieldset
If we clicked on the last link (confirmation), then we validate
all the fieldsets, otherwise we validate the previous one
before the form slided
*/
$('#steps').stop().animate({
marginLeft: '-' + widths[current-1] + 'px'
},500,function(){
if(current == fieldsetCount)
validateSteps();
else
validateStep(prev);
$('#formElem').children(':nth-child('+ parseInt(current) +')').find(':input:first').focus();
});
e.preventDefault();
});
/*
clicking on the tab (on the last input of each fieldset), makes the form
slide to the next step
*/
$('#formElem > fieldset').each(function(){
var $fieldset = $(this);
$fieldset.children(':last').find(':input').keydown(function(e){
if (e.which == 9){
$('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
/* force the blur for validation */
$(this).blur();
e.preventDefault();
}
});
});
/*
validates errors on all the fieldsets
records if the Form has errors in $('#formElem').data()
*/
function validateSteps(){
var FormErrors = false;
for(var i = 1; i < fieldsetCount; ++i){
var error = validateStep(i);
if(error == -1)
FormErrors = true;
}
$('#formElem').data('errors',FormErrors);
}
/*
validates one fieldset
and returns -1 if errors found, or 1 if not
*/
function validateStep(step){
if(step == fieldsetCount) return;
var error = 1;
var hasError = false;
$('#formElem').children(':nth-child('+ parseInt(step) +')').find(':input.required:not(button)').each(function(){
var $this = $(this);
var valueLength = jQuery.trim($this.val()).length;
if(valueLength == ''){
hasError = true;
$this.css('background-color','#333333');
}
else
$this.css('background-color','#000000');
});
var $link = $('#navigation li:nth-child(' + parseInt(step) + ') a');
$link.parent().find('.error,.checked').remove();
var valclass = 'checked';
if(hasError){
error = -1;
valclass = 'error';
}
$('<span class="'+valclass+'"></span>').insertAfter($link);
return error;
}
/*
if there are errors don't allow the user to submit
*/
$('#registerButton').bind('click',function(){
if($('#formElem').data('errors')){
alert('Please correct the errors in the Form');
return false;
}
});
});
Exactement ce que vous voulez faire glisser? – Zlatev
Par exemple, si vous cliquez sur Fournir votre contact en bas, il passe à l'étape suivante. Fondamentalement, quand ils cliquent sur un paquet, il devrait glisser à l'étape suivante. @Zlatev – Alex