Jump to content
Sign in to follow this  
dmikramar

Помощь с доработкой опросника

Recommended Posts

Помогите с выводом опросника не алертом, а на страницу в div

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0042)http://papermashup.com/demos/dynamic-form/ -->
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


<title>опросник</title>
<script type="text/javascript" src="jquery.js"></script>
<script>
$(document).ready(function(){




var i = $('input').size() + 1;


$('#add').click(function() {


$('<div><input type="text" class="field" name="dynamic[]" ></div>').fadeIn('slow').appendTo('.inputs');


i++;
});


$('#remove').click(function() {
if(i > 1) {
$('.field:last').remove();
i--; 
}
});


$('#reset').click(function() {
while(i > 2) {
$('.field:last').remove();
i--;
}
});




// here's our click function for when the forms submitted


$('.submit').click(function(){




var answers = [];
    $.each($('.field'), function() {
        answers.push($(this).val()); 
    });


    if(answers.length == 0) { 
        answers = "none"; 
    }   


alert(answers);


return false;


});






});


</script>


<style>
input{
border:1px solid #ccc;
padding:8px;
font-size:14px;
width:300px;
}


.submit{
width:110px;
background-color:#FF6;
padding:3px;
border:1px solid #FC0;
margin-top:20px;} 


</style>






<body>


<div id="container">


<div class="dynamic-form">


<a href="#" id="add">Добавить</a> | <a href="#" id="remove">Удалить</a>  | <a href="#" id="reset">Сбросить</a>  


<form>
<div class="inputs">
<div>Введите вопрос: <input type="text" name="dynamic[]" class="field" value="Вопрос"></div>
</div>
<input name="submit" type="button" class="submit" value="ОК">
</form>
</div>










</div>


</body></html>

 

Edited by Tom

Share this post


Link to post
Share on other sites
$(".element_name").html("<b>result</b>");

Оно? Алерта в скрипте я вообще не увидел.

Share this post


Link to post
Share on other sites
$(".element_name").html("<b>result</b>");

Оно? Алерта в скрипте я вообще не увидел.

 

Алерт в конце есть

$('.submit').click(function(){
 
 
var answers = [];
    $.each($('.field'), function() {
        answers.push($(this).val()); 
    });
 
    if(answers.length == 0) { 
        answers = "none"; 
    }   
 
alert(answers);
 
return false;
 
});
 
 
 
Помогите подробней пожалуйста, очень нужно.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.