Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> jak napisać poprawnie warunek
berdyk
post 6.04.2005, 11:43:36
Post #1





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 30.05.2003

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


mama pole
Kod
<input type="file" name="uploadedfiles[1]">
i chciałbyn sprawdzić czy user wybrał plik do przesłania na serwer za ponocą java.
mam warunek w funkcji check()
Kod
if (document.uploaddoc.uploadedfiles[1].checked == false) {
  alert("Proszę wybrać chociaż jeden plik do przesłania")
  document.uploaddoc.uploadedfiles[1].focus()
  return false}
gdzie uploadodc jest nazwą formularza do wysyłania. oczywiście warunek nie sprawdza i pozwala userowi na dokonanie uploud'u

Proszę o pomoc

pozdrawiam sadsmiley02.gif


--------------------
PHP @ all.
<? while ($cash==0) { $work=0; } ?>
Go to the top of the page
+Quote Post
revyag
post 6.04.2005, 12:12:02
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 258
Pomógł: 16
Dołączył: 21.09.2004
Skąd: Kielce

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


Pole input file chyba nie ma własności checked, hmm ?
Można to prosto zrobić. Sprawdzaj czy atrybut value jest pusty jak jest pusty to znaczy ze nie ma pliku.
Kod
if (document.uploaddoc.uploadedfiles[1].value =="")


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

------
Go to the top of the page
+Quote Post
berdyk
post 6.04.2005, 12:19:10
Post #3





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 30.05.2003

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


To właśnie też nie dzaiła
Nie sprawdzałem w IE
ale w poerze napewno NIE


--------------------
PHP @ all.
<? while ($cash==0) { $work=0; } ?>
Go to the top of the page
+Quote Post
piechnat
post 6.04.2005, 15:57:07
Post #4





Grupa: Zarejestrowani
Postów: 45
Pomógł: 0
Dołączył: 5.12.2004

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


jezeli pole nazywa sie:
Kod
name="uploadedfiles[1]"

to musisz sie do niego inaczej odwolac:
Kod
document.uploaddoc['uploadedfiles[1]'].value
Go to the top of the page
+Quote Post
berdyk
post 6.04.2005, 22:30:06
Post #5





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 30.05.2003

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


dzięki to zadzaiłało
a da się jednocześnie sprawdzić pięć takich samych inputów tz
Kod
<input type="file" name="uploadedfiles[]">
czy przynajmniej jeden z nich jest niepusty.
jeszcze raz dzięki worriedsmiley.gif


--------------------
PHP @ all.
<? while ($cash==0) { $work=0; } ?>
Go to the top of the page
+Quote Post
piechnat
post 6.04.2005, 22:47:19
Post #6





Grupa: Zarejestrowani
Postów: 45
Pomógł: 0
Dołączył: 5.12.2004

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


Kod
<script>
function checkForm(t) {
  var uF = t['uploadedfiles[]']
  for (var i = 0; i < uF.length; i++) {
    if (uF[i].value != '') return true
  }
  alert('Proszę wybrać chociaż jeden plik do przesłania')
  uF[0].focus()
  return false
}
</script>
<form action="" onsubmit="return checkForm(this)">
  <input type="file" name="uploadedfiles[]">
  <input type="file" name="uploadedfiles[]">
  <input type="file" name="uploadedfiles[]">
  <input type="file" name="uploadedfiles[]">
  <input type="file" name="uploadedfiles[]">
  <input type="submit">
</form>
Go to the top of the page
+Quote Post
berdyk
post 6.04.2005, 22:59:45
Post #7





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 30.05.2003

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


trochę zakręco ne ale rozumiem
dzięki serdeczne

czyli da się to zrobić z nieograniczoną liczbę kontrolek formularza smile.gif



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


i jeszcze jedno pytanie

mam funkcję

Kod
function Blokujuploaddoc(i)
{
    var status;
    var i;
    
    //document.uploaddoc['uploadedfiles['+ i +']'].disabled = true;
    
    status = (document.uploaddoc['cupload['+ i +']'].checked == false)? true : false;

    if(document.uploaddoc['cupload['+ i +']'].checked == false)
    {
        document.uploaddoc['uploadedfiles['+ i +']'].disabled = status;
    }
    else
    {
        document.uploaddoc['uploadedfiles['+ i +']'].disabled = status;
    }
}


czego tu brakuje żeby po załadowaniu strony pola document.uploaddoc['uploadedfiles['+ i +']'] pyły niedostępne

Ten post edytował berdyk 7.04.2005, 10:33:03


--------------------
PHP @ all.
<? while ($cash==0) { $work=0; } ?>
Go to the top of the page
+Quote Post
piechnat
post 7.04.2005, 19:46:11
Post #8





Grupa: Zarejestrowani
Postów: 45
Pomógł: 0
Dołączył: 5.12.2004

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


niedostepne tzn nieaktywne czy niewidoczne ?

jak nieaktywne to daj w tagu input:
Kod
<input type="file" disabled="disabled" />


a jak niewidoczne to mozna przeciez tworzyc dynamicznie lub usuwac nowe pola input, ja bym obstawial za takim rozwiazaniem, ale jak wolisz...
Go to the top of the page
+Quote Post
berdyk
post 7.04.2005, 22:24:23
Post #9





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 30.05.2003

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


to czemu nie napisałeś tego drugiego rozwiązania odrazu
nie zadawałbym teego pytania teraz

pozdrawiam



Kod
function onSChange() {

var kolejny = document.getElementById('uploadedfiles[]');

var option = document.createElement('input');
kolejny.add(option);
}


obiekt nie obsługuje tej właściwości lub metody


sadsmiley02.gif

Ten post edytował berdyk 7.04.2005, 23:13:35


--------------------
PHP @ all.
<? while ($cash==0) { $work=0; } ?>
Go to the top of the page
+Quote Post
piechnat
post 8.04.2005, 01:23:28
Post #10





Grupa: Zarejestrowani
Postów: 45
Pomógł: 0
Dołączył: 5.12.2004

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


Kod
<script>
function dodaj() {
 var ip, fc
 ip = document.createElement('input')
 fc = document.getElementById('files_container')
 ip.setAttribute('name', 'uploadedfiles[]')
 fc.appendChild(ip)
}
function usun() {
 var fc, ips
 fc = document.getElementById('files_container')
 ips = fc.getElementsByTagName('input')
 if (ips.length) fc.removeChild(ips[ips.length - 1])
}
</script>
<form>
 <a href="javascript:dodaj()">Dodaj</a>
 <a href="javascript:usun()">Usun</a>
 <div id="files_container"></div>
 <input type="submit">
</form>


Ten post edytował piechnat 8.04.2005, 01:24:47
Go to the top of the page
+Quote Post
berdyk
post 8.04.2005, 14:17:28
Post #11





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 30.05.2003

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


funkcję
Kod
function dodaj() {
var ip, fc
ip = document.createElement('input')
fc = document.getElementById('files_container')
ip.setAttribute('type', 'file')
ip.setAttribute('class', 'log')//style=\"width: 430px\
ip.setAttribute('style', 'width: 430px')
ip.setAttribute('name', 'uploadedfiles[]')
fc.appendChild(ip)
}
własnie tak sobie przerobiłem
problem teraz polega na tym że daje wszystko w jedenj lini

Jak zrobić by dawal linia pod linią
a najlepiej jak to umieścić w tabelikażdy input w
  1. <tr>
  2. <td><input></td>
  3. </tr>
  4. <tr>
  5. <td><input></td>
  6. </tr>
  7. <!-- i tak dalej -->


pozdrawiam

Ten post edytował berdyk 8.04.2005, 14:18:29


--------------------
PHP @ all.
<? while ($cash==0) { $work=0; } ?>
Go to the top of the page
+Quote Post
piechnat
post 8.04.2005, 18:06:23
Post #12





Grupa: Zarejestrowani
Postów: 45
Pomógł: 0
Dołączył: 5.12.2004

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


ojj... troche samodzielnosci, to juz jest analogiczna sprawa:

Kod
<script>
function dodaj() {
  var tr, td, ip, fc
  tr = document.createElement('tr')
  td = document.createElement('td')
  ip = document.createElement('input')
  fc = document.getElementById('files_container')
  ip.setAttribute('type', 'file')
  ip.setAttribute('class', 'log')
  ip.setAttribute('style', 'width: 430px')
  ip.setAttribute('name', 'uploadedfiles[]')
  fc.appendChild(tr)
  tr.appendChild(td)
  td.appendChild(ip)
}
function usun() {
  var fc, trs
  fc = document.getElementById('files_container')
  trs = fc.getElementsByTagName('tr')
  if (trs.length) fc.removeChild(trs[trs.length - 1])
}
</script>
<form>
  <a href="javascript:dodaj()">Dodaj</a>
  <a href="javascript:usun()">Usun</a>
  <table><tbody id="files_container"></tbody></table>
  <input type="submit">
</form>
Go to the top of the page
+Quote Post
berdyk
post 9.04.2005, 23:41:06
Post #13





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 30.05.2003

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


dziękuję ci bardzo serdecznie
ja jestem do tego stopnia zielony z java ze musze prawie o wszystko pytać
pozdrawiam


--------------------
PHP @ all.
<? while ($cash==0) { $work=0; } ?>
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: 18.07.2025 - 01:34