1 (edited by Deivs 2010-11-02 15:11:41)

Topic: type='image' kaip submitint forma?

HTML kodas:

<!-- Search -->
            <div id="search">
                <form name="Forma" action="" method="post">
                    <div id="search_input">
                        <input name="search" type="text" class="search_input" value="Paieška..."  onclick="this.value=''" />
                    </div>
                    <div id="search_button">
                        <input name="ieskoti" type="image" src="images/search_button.jpg" class="submit_search" />
                    </div>
                </form>
            </div>
            <!-- /Search -->

Kai type='submit' viskas OK, bet kai type='image', nesubmitina. Gal su onclick="" kaip nors iseitu submitint?

PHP patikrinti:

if(isset($_POST['ieskoti'])){
    $search = $_POST['search'];
    echo $search;
    
    //$sql = mysql_query("INSERT INTO `search` (`count`, `text`) VALUES ('1', '$search')");
}

Re: type='image' kaip submitint forma?

nu tai formai priskirk koki id, tarkim:

<form id="tavoForma"...

ir tada ant to savo inputo dedi oclick

<input type="image" onclick="document.getElementById('tavoForma').submit();"...
Su sąlyga, kad šūdo nebus...

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 816

Re: type='image' kaip submitint forma?

Taip, formos submit'as vyksta tik tada, kai paspaudžiamas submit tipo mygtukas. Visi kiti elementai formos nesubmitina. si JS (onClick="") gali bandyti:

.. onClick="this.form.submit();" ..

4 (edited by Deivs 2010-11-02 22:06:02)

Re: type='image' kaip submitint forma?

Neveikia kažkodėl, bandžiau taip:

<form name="tavoForma" id="tavoForma" action="" method="post">
                    <div id="search_input">
                        <input name="search" type="text" class="search_input" value="Paieška..."  onclick="this.value=''" />
                    </div>
                    <div id="search_button">
                        <input name="ieskoti" type="image" src="images/search_button.jpg" onclick="document.getElementById('tavoForma').submit(); class="submit_search" />
                    </div>
                </form>

Ir su mindės pavyzdžiu. Nors pakeitus į type='submit', tai suveikia. tarkim     <input name="ieskoti" type="submit" src="images/search_button.jpg" onclick="document.getElementById('tavoForma').submit();" class="submit_search" />

Re: type='image' kaip submitint forma?

Katik pabandžiau, tikrai veikia, test.php:

<?php
print_r($_REQUEST);
?>
<form name="tavoForma" id="tavoForma" action="" method="post">
<input name="ieskoti" type="image" src="http://www.google.lt/intl/en_com/images/srpr/logo1w.png" onclick="this.form.submit();" />
</form>

Pas tave tikriausiai kažkas su PHP scriptu blogai bus, arba yra kitas JS, kuris perima/trukdo event'ams.


Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 816

6 (edited by Deivs 2010-11-02 22:57:27)

Re: type='image' kaip submitint forma?

Su print_r($_REQUEST); gaunu taip:

Array ( [search] => testas [ieskoti_x] => 11 [ieskoti_y] => 8

Tai kaip ir veikia, bet kodel, neiseina cia gauti:

if(isset($_REQUEST['ieskoti'])){

    $search = $_POST['search'];
    echo $search;
}

Kaip pasiimti teksta is <input name='search' type="text"... /> siuo atveju?


Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 811

Deprecated: Function create_function() is deprecated in /home/pasokime/domains/mysql.lt/public_html/forumas/include/parser.php on line 816

Re: type='image' kaip submitint forma?

Todėl, kad paveiksliuko tipo elementas (type="image") per formą perduoda tik koordinates, kur tame paveiksliuke buvo paspausta. Taigi tikrink būtent "ieskoti_x" ir "ieskoti_y".

Teksta iš text tipo elemento pasiimti kaip ir anksčiau.

8 (edited by Deivs 2010-11-02 23:40:13)

Re: type='image' kaip submitint forma?

Dėkui, viskas veikia. Dar kartu norėčiau paklausti, kodėl neišeina perduoti lietuviškų raidžių address langelyje? na darau taip: .../vardai/ž arba index.php?raide=ž, su kitom raidėm tarkim A, B, C viskas ok, gaunu visus rezultatus, o jei š, č ar pan. Tai gaunasi notice offset 0... error'as.

Re: type='image' kaip submitint forma?

notice - yra PHP pranešima - vadinasi tavo script'as kažko neapdoroja (nerastas masyvo indeksas ar pan.). Beto lietuviškos raidės URL'e yra nerekomenduojama, jas reikia užkoduoti pagal URL taisykles (google: url encodind).