JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 4th, 2010, 12:48 PM
cinek cinek is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 2 cinek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 20 m 26 sec
Reputation Power: 0
Submit form w/o refresh help

I'm trying to submit a form without refreshing the page and I'm not having much luck. The form just resets and nothing is added to the database. The php script works fine as when I use form action - everything is added to the db. Here's the html form:

Code:
     <div id="form">
                
                    <form method="post" action="" id="form">
                        <label for="sections" id="wybierz">Wybierz sekcje</label>
                        <select id="sections" name="sections">
                            <option value="sekcjaA">Sekcja A</option>
                            <option value="sekcjaB">Sekcja B</option>
                        </select>
                        
                        <!-- Chose font & background color -->
                        <label for="fontcolor1" id="colorsLabel">Wybierz kolor czcionki/ tla </label>
                        <input class="color" id="fontcolor" name="fontColor" value="F0000F" /> <input class="color" id="bgcolor" name="bgcolor" value="ebebeb" />
                        
                        
                        <!-- Chose font -->
                        <label for="font" id="choseFontLabel">Wybierz typ/ rozmiar czcionki<abbr title="Wybierz typ oraz rozmiar czcionki">(?)</abbr></label>
    
                        <select id="font" name="font">
                            <option value="Arial" id="arial">Arial</option>
                            <option value="Comic Sans Ms">Comic Sans MS</option>
                            <option value="Courier New">Courier New</option>
                            <option value="Georgia">Georgia</option>
                            <option value="Impact" id="impact">Impact</option>
    
                            <option value="Tahoma">Tahoma</option>
                            <option value="Times New Roman">Times New Roman</option>
                            <option value="Verdana">Verdana</option>
                            <option value="Geneva">Geneva</option>
                            <option value="Trebuchet MS">Trebuchet MS</option>
                        </select>
    
                        <!-- End chose font -->
                        
                        <!-- Chose font size -->
                        <select id="fontSize" name="fontSize">
                            <option value="9">9px</option>
                            <option value="10">10px</option>
                            <option value="11">11px</option>
                            <option value="12">12px</option>
    
                            <option value="13">13px</option>
                            <option value="14">14px</option>
                            <option value="15">15px</option>
                            <option value="16">16px</option>
                            <option value="17">17px</option>
                            <option value="18">18px</option>
    
                            <option value="19">19px</option>
                            <option value="20">20px</option>
                        </select>
                        <!-- End chose font size -->
                        
                        <!-- Chose line height -->
                        <label for="lineHeight" id="lineHeightLabel">Wybierz wysokosc interlini/ odstep miedzy znakami</label>
                        <select id="lineHeight" name="lineHeight">
    
                            <option value="8">8px</option>
                            <option value="10">10px</option>
                            <option value="11">11px</option>
                            <option value="12">12px</option>
                            <option value="13">13px</option>
                            <option value="14">14px</option>
    
                            <option value="15">15px</option>
                            <option value="16">16px</option>
                            <option value="17">17px</option>
                            <option value="18">18px</option>
                            <option value="19">19px</option>
                            <option value="20">20px</option>
    
                            <option value="21">21px</option>
                            <option value="22">22px</option>
                            <option value="23">23px</option>
                            <option value="24">24px</option>
                            <option value="25">25px</option>
                            <option value="26">26px</option>
    
                            <option value="27">27px</option>
                            <option value="28">28px</option>
                            <option value="29">29px</option>
                            <option value="30">30px</option>
                        </select>
                        <!-- End chose line height -->
                        
                        <!-- Chose letter spacing -->
    
                        <select id="letterSpacing" name="letterSpacing">
                            <option value="1">1px</option>
                            <option value="2">2px</option>
                            <option value="3">3px</option>
                            <option value="4">4px</option>
                            <option value="5">5px</option>
    
                            <option value="6">6px</option>
                            <option value="7">7px</option>
                            <option value="8">8px</option>
                            <option value="9">9px</option>
                            <option value="10">10px</option>
                        </select>
    
                        <!-- End chose letter spacing -->    
                        
                        <select id="fontStyle" name="fontStyle">
                            <option value="Normal">Normal</option>
                            <option value="Italic">Italic</option>
                            <option value="Bold">Bold</option>                        
                        </select>
    
                        
                                     
                        <label for="tekst" id="wprowadz">Wprowadz tekst</label>
                        
                        
                        <input type="button" value="PL" id="PL" onclick="readyTextPL();" />
                        <input type="button" value="ENG" id="ENG" onclick="readyTextENG();" />
                        <input type="button" value="Lorem..." id="lorem" onclick="readyTextLorem();" />
                       
                        
                        <textarea cols="45" rows="5" name="tekst" id="tekst" onclick="clearTextarea();"></textarea>
                             
                        
                        
                        <label for="add" id="addLabel">Dopisz <abbr title="Dopisz do wybranej sekcji">(?)</abbr></label>
                        
                                            
                        <input type="checkbox" value="Dodaj" id="add" />
                        <input type="button" value="Wykonaj" id="wykonaj" onclick="copyText();" />
    
                        <input type="button" value="Wyczysc Formularz" id="clear" onclick="clearAll();" />
                        
                        <input type="submit" value="Zapisz" id="save" class="save" /> <span class="success" style="display:none"> Registration Successfully</span>
                    </form>



here's the script file I'm using:
EDIT
I removed the success bit, the table is now created (from the php file), but no data is submited - all fields are empty ;/


here's the new js

Code:
// JavaScript Document
$(function(){
$('.save').click(function(){
    
    var sections = $('input#sections').val();
    var fontColor = $('input#fontcolor').val();
    var bgcolor = $('input#bgcolor').val();
    var font = $('input#font').val();
    var fontSize = $('input#fontSize').val();
    var lineHeight = $('input#lineHeight').val();
    var letterSpacing = $('input#letterSpacing').val();
    var fontStyle = $('input#fontStyle').val();
    //Datastring to pass through
    
    var dataString = 'sections=' + sections + '&fontColor' + fontColor + '&bgcolor' + bgcolor + '&font' + font + '&fontSize' + fontSize +  '&lineHeight' + lineHeight + '&letterSpacing' + letterSpacing +  '&fontStyle' + fontStyle;
    
    $.ajax({
type: "POST",
url: "update.php",
data: dataString,

        
    });
    
});
});

any ideas what's wrong?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Submit form w/o refresh help


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap