Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [ajax] Problem z getlemenetbyid
atomp3
post 18.12.2007, 10:36:39
Post #1





Grupa: Zarejestrowani
Postów: 126
Pomógł: 1
Dołączył: 31.03.2006

Ostrzeżenie: (0%)
-----


Witam

Mam taka funkcje

  1. <?php
  2. function save_menu() {
  3.  
  4. var link_title=document.getElementById("link_title").value;
  5. var link_address=document.getElementById("link_address").value;
  6.  
  7. requestInfo('admin.php?dpt=users&sub=view&action=insert' 'showTable','');
  8. }
  9. ?>


Poniewaz dosc czesto bede jej uzywal chcialbym to troszke zautomatyzowac.

Jak napisac funkcje ktora zczyta automatycznie wszystkie id z formularza i wysle w linku?

Pozdrawiam
Go to the top of the page
+Quote Post
nospor
post 18.12.2007, 10:42:21
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Ale jaki to ma związek z ajaxem? Zaden. Przenosze


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
stoprocent
post 18.12.2007, 12:32:42
Post #3





Grupa: Zarejestrowani
Postów: 338
Pomógł: 2
Dołączył: 17.05.2003
Skąd: Kraków , Londyn

Ostrzeżenie: (0%)
-----


Chlopie uzyj sobie jakiegos jQuery czy innego Frameworka JS gdzie masz selectory.

w jQuery :

Kod
$("#form_id")
.find("input[@checked], input[@type='text'], input[@type='hidden'], input[@type='password'], input[@type='submit'], option[@selected], textarea")
.filter(":enabled")
.each(function() {
   // I tu juz masz petle dla kazdego elementu z formularza ().
});


nie w jquery
Kod
var form = document.getElementById("form_id");

var select     = form.getElementsByTagName("select");
var textarea = form.getElementsByTagName("textarea");
var input      = form.getElementsByTagName("textarea");


// Pozniej mergujesz tablice uzywajaca .push() i wrzucacsz wszytko w jednego for'a


--------------------
Go to the top of the page
+Quote Post
slammer
post 18.12.2007, 12:54:15
Post #4





Grupa: Zarejestrowani
Postów: 187
Pomógł: 6
Dołączył: 31.08.2005
Skąd: Bielsko-Biała

Ostrzeżenie: (0%)
-----


nie wiem czy dokładnie o to Ci chodzi, ale ja bym kombinował coś takiego:
  1. url = function(oForm){
  2. var url;
  3. url = 'admin.php?'
  4. for(var i=0;i<oForm.elements.length;i++){
  5. if(oForm.elements[i].type == "text"){
  6. url += oForm.elements[i].id+'='+oForm.elements[i].value+'&';
  7. }
  8. }
  9. alert(url.substring(0, url.length-1));
  10. }
  11. <input type="text" id="input1" name="input1" />
  12. <input type="text" id="input2" name="input1" />
  13. <input type="button" onclick="url(this.form)" value="pokaz url" />
  14. </form>
Go to the top of the page
+Quote Post
atomp3
post 18.12.2007, 13:53:33
Post #5





Grupa: Zarejestrowani
Postów: 126
Pomógł: 1
Dołączył: 31.03.2006

Ostrzeżenie: (0%)
-----


Cytat(slammer @ 18.12.2007, 12:54:15 ) *
nie wiem czy dokładnie o to Ci chodzi, ale ja bym kombinował coś takiego:
  1. url = function(oForm){
  2. var url;
  3. url = 'admin.php?'
  4. for(var i=0;i<oForm.elements.length;i++){
  5. if(oForm.elements[i].type == "text"){
  6. url += oForm.elements[i].id+'='+oForm.elements[i].value+'&';
  7. }
  8. }
  9. alert(url.substring(0, url.length-1));
  10. }
  11. <input type="text" id="input1" name="input1" />
  12. <input type="text" id="input2" name="input1" />
  13. <input type="button" onclick="url(this.form)" value="pokaz url" />
  14. </form>




DZIALA super! smile.gif dzieki za pomoc
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 20.07.2025 - 06:03