The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Submit without reload, Submit without reload but let firefox save the input
mike85
post Jan 30 2011, 01:31 PM
Post #1





Group: Members
Posts: 3
Joined: 30-January 11
Member No.: 13,743



Hello there,

I want to build a form which invokes an ajax-function and therefore the page shouldn't reload.

The problem is I don't want to avoid the autocompletion of the browser. But to save the input i have to submit the form regularly, which means 'onSubmit="return false;"' doesn't work.

Is there any possibility or is this technique just impossible?

Thx for reading and thinking about it!


This is the current code, which works fine, but the browser doesn't save the (non-)submitted input.
(The submit will be invoked by the "getSuggests()"-function.)

CODE

        <form id="mytaste-selection" name="mytaste-selection" autocomplete="on" onSubmit="return false;">
            <fieldset>
                <legend>
                Search
                </legend>
                <div style="padding: 0px 0px;">
                    <label class="standard">Artist:</label>
                    <input id="mytaste-artist" name="mytaste-artist" class="standard text" type="text" autocomplete="on"/>
                    <label class="standard">Title:</label>
                    <input id="mytaste-title" name="mytaste-title" class="standard text" type="text" autocomplete="on"/>
                </div>
                <div class="button" onclick="getSuggests(urlEncode(getElementById('mytaste-artist').value),urlEncode(getElementById('mytaste-title').value),(getElementById('top').checked)?'top':'similar');">
                Search
                </div>
                <div>
                    <label class="standard">Top Tracks</label>
                    <input class="standard radio" name="method_type" id="top" type="radio" checked="checked"/>
                    <label class="standard" style="margin: 2px 2px 2px 20px;">Similar Tracks</label>
                    <input class="standard radio" name="method_type" id="similar" type="radio"/>
                </div>
            </fieldset>

        </form>


PS: you can have a look at the page at http://mytaste.alitility.com

This post has been edited by mike85: Jan 30 2011, 01:34 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
mike85
post Jan 30 2011, 05:09 PM
Post #2





Group: Members
Posts: 3
Joined: 30-January 11
Member No.: 13,743



Got that answer:

What you can do is add a "target" attribtute to your form, which points to a hidden iframe. That way, you don't have to return false in your onsubmit, you just do your ajax thing, and let the form do its normal submission — the page won't be reloaded; the URL you specified in the "action" attribute will only be opened in the hidden iframe. You can set that URL to just a blank page, since you're handling the real submission with AJAX.

So I'm already fine.. thx for your time...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 04:51 PM