Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [html][php]formy
Forum PHP.pl > Forum > Przedszkole
gutek84
Mam dwie formy.W pierwszej menu, w drugiej tabelke z checkboxami. Jak zrobic aby po wybraniu odpowiedniej opcji w menu i potwierdzeniu submitem zmienily mi sie rzeczy zaznaczone w drugiej formie.
pozdr
Maxik
Z przeładowaniem strony czy bez?
gutek84
Moze byc z przeładowaniem.
Maxik
No to wysyłasz formularz, a przy w kodzie checkboxa dajesz
  1. <?php
  2. if($_GET['cos']){
  3. echo "CHECKED";
  4. }
  5. ?>


Dostosuj sobie.
gutek84
Zle troche to sprecyzowalem.Korzystam ze smartiego. Mam dwie formy w dwoch roznych divach. Z tych dwoch form potrzebuje wyslac do innego pliku wartosci tj. w przypadku edycji np. id ktore ma zostac przypisane dla zaznaczonych elementow w chceckboxach.

pierwsza forma:
Kod
<form name="chk" action="index.php" method="get" id="1">
  <input type="hidden" value="inventarization" name="show">
  <input type="hidden" value="check" name="action">
  <input type="hidden" value="{$room}" name="room">
  <input type="hidden" value="go" name="step3">
  <input type="hidden" value="{$zm}" name="option">
  {foreach item=i from=$inv_item2}
  <input type="hidden" name="inv[{$smarty.foreach.inv_item2.iteration}]" value="{$i.i_barcode}">{/foreach}
  
  {if $zm eq "owner"}
<select name="own" size="1">
<option>Select New Owner&nbsp;&nbsp;</option>
          {foreach item=ang from=$chown}
          <option value="{$ang.angestellterid}">{$ang.person}&nbsp;</option>
          {/foreach}
          <input type="submit" value="Change">
              </select>
{elseif $zm eq "room" }
    <select name="roomid" size="1">
    <option>Select New Room number&nbsp;&nbsp;</option>
  {foreach item=r from=$rnr}
  <option value="{$r.r_id}">{$r.r_roomnr}&nbsp;</option>
  {/foreach}
  <input type="submit" value="Change">
  </select>
  
{/if}
</form>


druga forma
Kod
<form method="get" name="chk" action="index.php" id="1">
  <input type="hidden" value="inventarization" name="show">
  <input type="hidden" value="check" name="action">
  <input type="hidden" value="{$room}" name="room">
  <input type="hidden" value="go" name="step3">
  <input type="hidden" value="{$zm}" name="option">
<table class="m648">
<tr>
<b>Step 3. In this step you can change room number or owner. If you want to do changes first you must <u><i>choose action!!!</i></u> In the other case click NEXT button. </b>
</tr>
<tr>
<b><th colspan="12">This table display inventar, which is now alocated in this room.</th></b>
</tr>
<tr>
<th colspan="2" width="20" ></th>
<th colspan="2" width="150">Category</th>
<th colspan="2" width="150">Name</th>
<th colspan="2" width="150">Room nr</th>
<th colspan="2" width="150">Owner</th>
<th colspan="2" width="200">Barcode</th>
</tr>
{foreach name="aa" item=inv_item from=$inv_item2}
<tr> <td colspan="2" align="center" >
<input type="checkbox" name="ch[]" value="{$inv_item.i_barcode}" /></td>
            <td colspan="2" align="center">{$inv_item.c_name}</td>
            <td colspan="2" align="center">{$inv_item.i_name}</td>
            <td colspan="2" align="center">{$inv_item.r_roomnr}</td>
            <td colspan="2" align="center">{$inv_item.owner}</td>
            <td colspan="2" align="center">{$inv_item.i_barcode}<input type="hidden" name="inv[{$smarty.foreach.inv_item2.iteration}]" value="{$inv_item.i_barcode}"></td>
    <td>
    <a href="index.php?barcode={$inv_item.i_barcode}&show=inventar&action=edit&roomid={$inv_item.i_roomid}">
    <img src="img/bearbeiten.gif" alt="EDIT">
    </a>
    </td>
</tr>
{/foreach}

<tr>
<b><th colspan="12">This table display inventar, which is alocated in this room and currently rented.</th></b>
</tr>
{foreach name="a" item=inv_item6 from=$rented}
<tr> <td colspan="2" align="center" >
<input type="checkbox" name="ch[]" value="{$inv_item6.i_barcode}" /></td>
            <td colspan="2" align="center">{$inv_item6.c_name}</td>
            <td colspan="2" align="center">{$inv_item6.i_name}</td>
            <td colspan="2" align="center">{$inv_item6.r_roomnr}</td>
            <td colspan="2" align="center">{$inv_item6.owner}</td>
            <td colspan="2" align="center">{$inv_item6.i_barcode}
            <input type="hidden" name="inv[{$smarty.foreach.rented.iteration}]" value="{$inv_item6.i_barcode}"></td>
    <td>
    <a href="index.php?barcode={$inv_item6.i_barcode}&show=inventar&action=edit&roomid={$inv_item6.i_roomid}">
    <img src="img/bearbeiten.gif" alt="EDIT">
    </a>
    </td>
</tr>
{/foreach}
<tr>
<b><th colspan="12">This table display inventar, which is not rented and not present but alocated in this room.</th></b>
</tr>
{foreach name="aaa" item=inv_item5 from=$notin}
<tr> <td colspan="2" align="center" >
<input type="checkbox" name="ch[]" value="{$inv_item5.i_barcode}" /></td>
            <td colspan="2" align="center">{$inv_item5.c_name}</td>
            <td colspan="2" align="center">{$inv_item5.i_name}</td>
            <td colspan="2" align="center">{$inv_item5.r_roomnr}</td>
            <td colspan="2" align="center">{$inv_item5.owner}</td>
            <td colspan="2" align="center">{$inv_item5.i_barcode}
            <input type="hidden" name="inv[{$smarty.foreach.not_in.iteration}]" value="{$inv_item5.i_barcode}"></td>
    <td>
    <a href="index.php?barcode={$inv_item5.i_barcode}&show=inventar&action=edit&roomid={$inv_item5.i_roomid}">
    <img src="img/bearbeiten.gif" alt="EDIT">
    </a>
    </td>
</tr>
{/foreach}
</table>
</tr>
<tr>
  <td colspan="12" align="center">
  <input type="reset" value="Zurücksetzen" onclick="javascript:history.go(-1);"/>
  <input type="submit" value="NEXT >"></td>
  </form>


W drugiej formie wyswietlam dane z 3 tablic w jednej tabelce. Przy kazdym mam checkboxa. Pierwszy listing to kawalek takiego jakby menu.

I teraz chodzi mi o to kiedy wybiore cos z menu np. change owner, wtedy wyskakuje mi dodatkowe pole z wyborem ownera i przyciskiem zatwierdz. Jesli zatwierdze, to wszystkie zaznaczone przedmioty musza miec takiego ownera jakiego wybralem.
Niestety nie dziala sad.gif, i nie wiem gdzie popełniam błąd. Proszę o pomoc.
koodlaty
Czyli jak myślę chodzi Ci o przesłanie danych z obu formularzy przy pomocy jednego przycisku?
gutek84
Dokładnie. Tylko nie mam pojecia jak to zrobic sciana.gif
Maxik
W JS można wywołać jakieś akcje np. kliknięcie danego button. Może to Ci pomoże.
gutek84
Probowalem onclick="document.chk.submit();document.change.submit();". Ale forma chk nie wysyla danych.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.