Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / (PHP) Отправка формы php + jquery / 6 сообщений из 6, страница 1 из 1
05.10.2012, 17:00:28
    #37985747
torment
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(PHP) Отправка формы php + jquery
Подскажите как отправить форму.

Есть сама форма, есть скрипт jquery, который ее обрабатывает.

вот код:

форма

+
Код: html
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
<div id="container">
        <!-- <form action="#" id="" name="registeruser" method="post"> -->
		<form id = "register" action="<? echo $PHP_SELF; ?>?action=register" method = "post" >
	
            <!-- #first_step -->
            <div id="first_step">
                <h1>SIGN UP FOR A FREE  ACCOUNT</h1>
				
                <div class="form">
					
					<input type="text" name="email" id="email" value="email address" />
                    <label for="email">Your email address. A confirmation email will arrive to this address. </label>

					<select id="registertype" name="registertype">
                        <option> Member </option>                     
                    </select>
					<label for="registertype"> User Type. </label> <!-- clearfix --><div class="clear"></div><!-- /clearfix -->
                </div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->
				<a class="buttons" name="submit_first" id="submit_first" href="#"> Next </a>                
            </div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->


            <!-- #second_step -->
            <div id="second_step">
                <h1>SIGN UP FOR A FREE  ACCOUNT</h1>

                <div class="form">
				
					<input type="text" name="username" id="username" value="username" />
                    <label for="username">At least 4 characters. Uppercase letters, lowercase letters and numbers only.</label>
                    
                    <input type="password" name="password" id="password" value="password" />
                    <label for="password">At least 4 characters. Use a mix of upper and lowercase for a strong password.</label>
                    
                    <input type="password" name="cpassword" id="cpassword" value="password" />
                    <label for="cpassword">If your passwords aren’t equal, you won’t be able to continue with signup.</label>

                </div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->
				<a class="buttons" name="submit_second" id="back_second" href="#"> Back </a> 
				<a class="buttons" name="submit_second" id="submit_second" href="#"> Next </a>                
            </div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->


            <!-- #third_step -->
            <div id="third_step">
                <h1>SIGN UP FOR A FREE  ACCOUNT</h1>

                <div class="form">
                    <select id="language" name="language">
                        <option> English </option>
                        <option> Italian </option>
                        <option> Russian </option>
                    </select>
                    <label for="language"> Select default language of the website. </label> <!-- clearfix --><div class="clear"></div><!-- /clearfix -->
                    
                    <select id="country" name="country">
                        <option>United States</option>
                        <option>United Kingdom</option>
                        <option>Canada</option>
                        <option>Serbia</option>
                        <option>Italy</option>
                    </select>
                    <label for="country">Your country. </label> <!-- clearfix --><div class="clear"></div><!-- /clearfix -->
                    
                </div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->
				<a class="buttons" name="submit_third" id="back_third" href="#"> Back </a>
				<a class="buttons" name="submit_third" id="submit_third" href="#"> Next </a>                
                
            </div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->
            
            
            <!-- #fourth_step -->
            <div id="fourth_step">
                <h1>SIGN UP FOR A FREE  ACCOUNT</h1>

                <div class="form">
                    <h2>Summary</h2>
                    
                    <table>
                        <tr><td>Username</td><td></td></tr>
                        <tr><td>Password</td><td></td></tr>
                        <tr><td>Email</td><td></td></tr>
                        <tr><td>Name</td><td></td></tr>
                        <tr><td>Language</td><td></td></tr>
                        <tr><td>Country</td><td></td></tr>                        
                    </table>
                </div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->
				<a class="buttons" name="submit_third" id="back_fourth" href="#"> Back </a>
				<a class="buttons" name="submit_fourth" id="submit_fourth" href="#"> Done </a> 
            </div>            
        </form>
		
	</div>
	<div id="progress_bar">
        <div id="progress"></div>
        <div id="progress_text">0% Complete</div>
	</div>



скрипт jquery
+

Код: javascript
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
$(function(){
    //original field values
    var field_values = {
            //id        :  value
            'username'  : 'username',
            'password'  : 'password',
            'cpassword' : 'password',
            'firstname'  : 'first name',
            'lastname'  : 'last name',
            'email'  : 'email address'
    };


    //inputfocus
    $('input#username').inputfocus({ value: field_values['username'] });
    $('input#password').inputfocus({ value: field_values['password'] });
    $('input#cpassword').inputfocus({ value: field_values['cpassword'] }); 
    $('input#lastname').inputfocus({ value: field_values['lastname'] });
    $('input#firstname').inputfocus({ value: field_values['firstname'] });
    $('input#email').inputfocus({ value: field_values['email'] }); 




    //reset progress bar
    $('#progress').css('width','0');
    $('#progress_text').html('0% Complete');

    //first_step
    $('form').submit(function(){ return false; });
    $('#submit_first').click(function(){
        //remove classes
        $('#first_step input').removeClass('error').removeClass('valid');
		
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
        var fields = $('#first_step input[type=text]');
        var error = 0;
        fields.each(function(){
            var value = $(this).val();
            if( value.length<1 || value==field_values[$(this).attr('id')] || ( $(this).attr('id')=='email' && !emailPattern.test(value) ) ) {
                $(this).addClass('error');
                $(this).effect("shake", { times:3 }, 50);
                
                error++;
            } else {
                $(this).addClass('valid');
            }
        });

        if(!error) {
                //update progress bar
                $('#progress_text').html('33% Complete');
                $('#progress').css('width','113px');
                
                //slide steps
                $('#first_step').slideUp();
                $('#second_step').slideDown();    
        } else return false;

    });


    $('#submit_second').click(function(){
        //remove classes
        $('#second_step input').removeClass('error').removeClass('valid');
		
		//ckeck if inputs aren't empty
        var fields = $('#second_step input[type=text], #second_step input[type=password]');
        var error = 0;
        fields.each(function(){
            var value = $(this).val();
            if( value.length<4 || value==field_values[$(this).attr('id')] ) {
                $(this).addClass('error');
                $(this).effect("shake", { times:3 }, 50);
                
                error++;
            } else {
                $(this).addClass('valid');
            }
        });        
        
        if(!error) {
            if( $('#password').val() != $('#cpassword').val() ) {
                    $('#second_step input[type=password]').each(function(){
                        $(this).removeClass('valid').addClass('error');
                        $(this).effect("shake", { times:3 }, 50);
                    });
                    
                    return false;
            } else {   
                //update progress bar
                $('#progress_text').html('66% Complete');
                $('#progress').css('width','226px');
                
                //slide steps
                $('#second_step').slideUp();
                $('#third_step').slideDown();     
            }               
        } else return false;

    });
	
	$('#back_second').click(function(){
		//update progress bar
        $('#progress_text').html('0% Complete');
        $('#progress').css('width','226px');
                
        //slide steps
        $('#second_step').slideUp();
        $('#first_step').slideDown(); 
	});

    $('#submit_third').click(function(){
        //update progress bar
        $('#progress_text').html('100% Complete');
        $('#progress').css('width','339px');

        //prepare the fourth step
        var fields = new Array(
            $('#username').val(),
            $('#password').val(),
            $('#email').val(),
            //$('#firstname').val() + ' ' + $('#lastname').val(),
            //$('#age').val(),
			$('#registertype').val(),
			$('#language').val(),
            //$('#gender').val(),
            $('#country').val()                       
        );
        var tr = $('#fourth_step tr');
        tr.each(function(){
            //alert( fields[$(this).index()] )
            $(this).children('td:nth-child(2)').html(fields[$(this).index()]);
        });
                
        //slide steps
        $('#third_step').slideUp();
        $('#fourth_step').slideDown();            
    });
	
	$('#back_third').click(function(){
		//update progress bar
        $('#progress_text').html('0% Complete');
        $('#progress').css('width','226px');
                
        //slide steps
        $('#third_step').slideUp();
        $('#second_step').slideDown(); 
	});


    $('#submit_fourth').click(function(){
        //send information to server
        //alert('Data sent');
		$("form#register").submit();
    });
	
	$('#back_fourth').click(function(){
		//update progress bar
        $('#progress_text').html('0% Complete');
        $('#progress').css('width','226px');
                
        //slide steps
        $('#fourth_step').slideUp();
        $('#third_step').slideDown(); 
	});

});



Пробовал отправлять по всякому.
в скрипте
Код: javascript
1.
2.
3.
4.
5.
$('#submit_fourth').click(function(){
        //send information to server
        //alert('Data sent');
		$("form#register").submit();
    });



просто втавить submit, onclickom, ничего не получается.
Самое интересное, что если вешаю на onclick id другой формы, она отправляется, а именно эта форма, нет.

Подскажите в чем проблема.

Модератор: Тема перенесена из форума "PHP, Perl, Python".
...
Рейтинг: 0 / 0
05.10.2012, 17:14:46
    #37985770
Паганель
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(PHP) Отправка формы php + jquery
а может, просто заменить ссылку submit_fourth на input с типом submit
?
...
Рейтинг: 0 / 0
05.10.2012, 17:18:25
    #37985773
torment
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(PHP) Отправка формы php + jquery
Так в том то и дело, что я пробовал вставить обычный input с submit, но форма по прежнему не отправляется.
...
Рейтинг: 0 / 0
05.10.2012, 17:24:11
    #37985783
skyANA
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(PHP) Отправка формы php + jquery
torment, может она у Вас внутри другой формы? Фидлер регистрирует какие-нибудь запросы?
...
Рейтинг: 0 / 0
05.10.2012, 17:24:15
    #37985784
Паганель
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(PHP) Отправка формы php + jquery
а если это
$('form').submit(function(){ return false; });
убрать?
...
Рейтинг: 0 / 0
05.10.2012, 17:35:41
    #37985797
torment
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
(PHP) Отправка формы php + jquery
Паганельа если это
$('form').submit(function(){ return false; });
убрать?

Спасибо огромное!
Скрипт взял готовым и не заметил эту строку! А я голову ломал!
...
Рейтинг: 0 / 0
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / (PHP) Отправка формы php + jquery / 6 сообщений из 6, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]