Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][PHP]Odblokowanie formularzu po kliknięciu
saviola15
post
Post #1





Grupa: Zarejestrowani
Postów: 62
Pomógł: 0
Dołączył: 6.09.2012

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


Witam
http://www.pneumaticon.pl/presta/authentic....php%3Fstep%3D1 Aby zobaczyć koszyk musicie jakiś produkt dać do koszyka. Po tym jak to wykonacie ukaże wam się "Dane do wysyłki" i poniżej opcja "firma" po kliknięciu w niego wyskoczy reszta formularzu. Chciałby aby po kliknięciu w osoba prywatna wyskoczyło wszystko to samo ale bez "nipu" i "Firma"

  1. <input type="radio" name="nazwa" value="wartość" onclick="document.getElementById('identyfikator').style.display = this.checked ? 'block' : 'none'; this.form.elements['nazwa2'].disabled = !this.checked" /> <b> Firma </b>
  2. <input type="radio" /> <b> Osoba Prywatna </b>
  3. <div id="identyfikator" style="display: none">
  4. <h3>{l s='Delivery address'}</h3>
  5. {foreach from=$dlv_all_fields item=field_name}
  6. {if $field_name eq "company"}
  7. <p class="text">
  8. <label for="company">{l s='Company'}</label>
  9. <input type="text" class="text" id="company" name="company" value="{if isset($smarty.post.company)}{$smarty.post.company}{/if}" />
  10. </p>
  11. {elseif $field_name eq "vat_number"}
  12. <div id="vat_number" style="display:none;">
  13. <p class="text">
  14. <label for="vat_number">{l s='VAT number'}</label>
  15. <input type="text" class="text" name="vat_number" value="{if isset($smarty.post.vat_number)}{$smarty.post.vat_number}{/if}" />
  16. </p>
  17. </div>
  18. {elseif $field_name eq "address1"}
  19. <p class="required text">
  20. <label for="address1">{l s='Address'}</label>
  21. <input type="text" class="text" name="address1" id="address1" value="{if isset($smarty.post.address1)}{$smarty.post.address1}{/if}">
  22. <sup>*</sup>
  23. </p>
  24. {elseif $field_name eq "postcode"}
  25. <p class="required postcode text">
  26. <label for="postcode">{l s='Zip / Postal Code'}</label>
  27. <input type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}" onblur="$('#postcode').val($('#postcode').val().toUpperCase());">
  28. <sup>*</sup>
  29. </p>
  30. {elseif $field_name eq "city"}
  31. <p class="required text">
  32. <label for="city">{l s='City'}</label>
  33. <input type="text" class="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{/if}">
  34. <sup>*</sup>
  35. </p>
  36. <!--
  37. if customer hasn't update his layout address, country has to be verified
  38. but it's deprecated
  39. -->
  40. {elseif $field_name eq "Country:name" || $field_name eq "country"}
  41. <p class="required select">
  42. <label for="id_country">{l s='Country'}</label>
  43. <select name="id_country" id="id_country">
  44. <option value="">-</option>
  45. {foreach from=$countries item=v}
  46. <option value="{$v.id_country}" {if ($sl_country == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'htmlall':'UTF-8'}</option>
  47. {/foreach}
  48. </select>
  49. <sup>*</sup>
  50. </p>
  51. {elseif $field_name eq "State:name"}
  52. {assign var='stateExist' value=true}
  53.  
  54. <p class="required id_state select">
  55. <label for="id_state">{l s='State'}</label>
  56. <select name="id_state" id="id_state">
  57. <option value="">-</option>
  58. </select>
  59. <sup>*</sup>
  60. </p>
  61. {elseif $field_name eq "phone"}
  62. <p class="text">
  63. <label for="phone">{l s='Phone'}</label>
  64. <input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}"> <sup style="color:red;">*</sup>
  65. </p>
  66. {/if}
  67. {/foreach}
  68. {if $stateExist eq false}
  69. <p class="required id_state select">
  70. <label for="id_state">{l s='State'}</label>
  71. <select name="id_state" id="id_state">
  72. <option value="">-</option>
  73. </select>
  74. <sup>*</sup>
  75. </p>
  76. {/if}
  77. <input type="hidden" name="alias" id="alias" value="{l s='My address'}">
  78. <input type="hidden" name="is_new_customer" id="is_new_customer" value="0">
  79. <!-- END Account -->
  80. </div>
  81. </fieldset>
  82. <fieldset class="account_creation dni">
  83.  
  84. <h3>{l s='Tax identification'}</h3>
  85.  
  86. <p class="required text">
  87. <label for="dni">{l s='Identification number'}</label>
  88. <input type="text" class="text" name="dni" id="dni" value="{if isset($smarty.post.dni)}{$smarty.post.dni}{/if}" />
  89. <span class="form_info">{l s='DNI / NIF / NIE'}</span>
  90. <sup>*</sup>
  91. </p>
  92. </fieldset>
  93. <p class="cart_navigation required submit">
  94. <span><sup>*</sup>{l s='Required field'}</span>
  95. <input type="submit" class="button" name="submitGuestAccount" id="submitGuestAccount" style="float:right" value="{l s='Continue'}">
  96. </p>
  97. </form>
  98. {/if}
  99. {else}
  100. <form action="{$link->getPageLink('authentication.php', true)}" method="post" id="account-creation_form" class="std">
  101. {$HOOK_CREATE_ACCOUNT_TOP}
  102. <fieldset class="account_creation">
  103.  
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
bostaf
post
Post #2





Grupa: Zarejestrowani
Postów: 374
Pomógł: 79
Dołączył: 6.04.2010
Skąd: Ostrów Wielkopolski

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


  1. Daj obu inputom (Firma i Osoba prywatna) taki sam name - tylko wtedy będzie to działało jak przycisk opcji, czyli będzie można wybrać tylko jedną opcję.
  2. Ukrywanie fragmentów strony można zrealizować za pomocą atrybutu CSS display. W prosty i niezbyt elegancki sposób możesz to zrealizować JavaScriptem zagnieżdżonym bezpośrednio w inputach:
    1. <input type="radio" name="platnik" value="osoba_prywatna" onClick="documet.getElementById('to_co_ma_sie_chowac_i_pokazywac').style.display='none';">
    2. <input type="radio" name="platnik" value="firma" onClick="documet.getElementById('to_co_ma_sie_chowac_i_pokazywac').style.display='';">

    to_co_ma_sie_chowac_i_pokazywac to nazwa atrybutu id fragmentu strony, np:
    1. <div id="to_co_ma_sie_chowac_i_pokazywac">Pojawiam się i znikam</div>

Na początku tego listingu, który wkleiłeś widać, że w dobrym kierunku kombinujesz. Uzupełnij to, czego brakuje wg moich wskazówek.
Go to the top of the page
+Quote Post
saviola15
post
Post #3





Grupa: Zarejestrowani
Postów: 62
Pomógł: 0
Dołączył: 6.09.2012

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


Dodałem taki kod i jest możliwość wyboru ale po kliknięciach nic się nie pokazuje (IMG:style_emoticons/default/sad.gif)

  1. <input type="radio" name="platnik" value="osoba_prywatna" onClick="documet.getElementById('to_co_ma_sie_chowac_i_pokazywac').style.display='none';"> Osoba Prywatna
  2. <input type="radio" name="platnik" value="firma" onClick="documet.getElementById('to_co_ma_sie_chowac_i_pokazywac').style.display='';"> Firma
  3.  
  4. <h3>{l s='Delivery address'}</h3>
  5. {foreach from=$dlv_all_fields item=field_name}
  6. {if $field_name eq "company"}
  7. <div id="to_co_ma_sie_chowac_i_pokazywac"><p class="text">
  8. <label for="company">{l s='Company'}</label>
  9. <input type="text" class="text" id="company" name="company" value="{if isset($smarty.post.company)}{$smarty.post.company}{/if}" />
  10. </p></div>
Go to the top of the page
+Quote Post
bostaf
post
Post #4





Grupa: Zarejestrowani
Postów: 374
Pomógł: 79
Dołączył: 6.04.2010
Skąd: Ostrów Wielkopolski

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


Cytat(saviola15 @ 16.10.2012, 22:57:38 ) *
Dodałem taki kod i jest możliwość wyboru ale po kliknięciach nic się nie pokazuje (IMG:style_emoticons/default/sad.gif)

Trochę zbyt dosłownie zacytowałeś to co Ci pokazałem (IMG:style_emoticons/default/smile.gif) To nie był gotowiec, tylko naprowadzenie.
Zobacz, masz tam tą sekcję z NIPem. Wrzuć całą między DIV z atrybutem "id=to_co_ma_sie_chowac_i_pokazywac".
Zobacz też i przeanalizuj ten przykładzik.
Go to the top of the page
+Quote Post
saviola15
post
Post #5





Grupa: Zarejestrowani
Postów: 62
Pomógł: 0
Dołączył: 6.09.2012

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


Hmm dodałem zwykły tekst i również nie działa. Zapomniałem, że jest to plik ".tpl" czyli technologia smarty... Jakieś sugestie ?

  1. <input type="radio" name="platnik" value="osoba_prywatna" onClick="documet.getElementById('to_co_ma_sie_chowac_i_pokazywac').style.display='none';"> Osoba Prywatna
  2. <input type="radio" name="platnik" value="firma" onClick="documet.getElementById('to_co_ma_sie_chowac_i_pokazywac').style.display='';"> Firma
  3. <div id="to_co_ma_sie_chowac_i_pokazywac">Podaj nip </div>
  4. <h3>{l s='Delivery address'}</h3>
  5. {foreach from=$dlv_all_fields item=field_name}
  6. {if $field_name eq "company"}
  7. <p class="text">
  8. <label for="company">{l s='Company'}</label>
  9. <input type="text" class="text" id="company" name="company" value="{if isset($smarty.post.company)}{$smarty.post.company}{/if}" />
  10. </p>
  11. {elseif $field_name eq "vat_number"}
  12. <div id="vat_number" style="display:none;">
  13. <p class="text">
  14. <label for="vat_number">{l s='VAT number'}</label>
  15. <input type="text" class="text" name="vat_number" value="{if isset($smarty.post.vat_number)}{$smarty.post.vat_number}{/if}" />
  16. </p>
  17. </div>
  18. {elseif $field_name eq "address1"}
  19. <p class="required text">
  20. <label for="address1">{l s='Address'}</label>
  21. <input type="text" class="text" name="address1" id="address1" value="{if isset($smarty.post.address1)}{$smarty.post.address1}{/if}">
  22. <sup>*</sup>
  23. </p>
  24. {elseif $field_name eq "postcode"}
  25. <p class="required postcode text">
  26. <label for="postcode">{l s='Zip / Postal Code'}</label>
  27. <input type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}" onblur="$('#postcode').val($('#postcode').val().toUpperCase());">
  28. <sup>*</sup>
  29. </p>
  30. {elseif $field_name eq "city"}
  31. <p class="required text">
  32. <label for="city">{l s='City'}</label>
  33. <input type="text" class="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{/if}">
  34. <sup>*</sup>
  35. </p>
  36. <!--
  37. if customer hasn't update his layout address, country has to be verified
  38. but it's deprecated
  39. -->
  40. {elseif $field_name eq "Country:name" || $field_name eq "country"}
  41. <p class="required select">
  42. <label for="id_country">{l s='Country'}</label>
  43. <select name="id_country" id="id_country">
  44. <option value="">-</option>
  45. {foreach from=$countries item=v}
  46. <option value="{$v.id_country}" {if ($sl_country == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'htmlall':'UTF-8'}</option>
  47. {/foreach}
  48. </select>
  49. <sup>*</sup>
  50. </p>
  51. {elseif $field_name eq "State:name"}
  52. {assign var='stateExist' value=true}
  53.  
  54. <p class="required id_state select">
  55. <label for="id_state">{l s='State'}</label>
  56. <select name="id_state" id="id_state">
  57. <option value="">-</option>
  58. </select>
  59. <sup>*</sup>
  60. </p>
  61. {elseif $field_name eq "phone"}
  62. <p class="text">
  63. <label for="phone">{l s='Phone'}</label>
  64. <input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}"> <sup style="color:red;">*</sup>
  65. </p>
  66. {/if}
  67. {/foreach}
  68. {if $stateExist eq false}
  69. <p class="required id_state select">
  70. <label for="id_state">{l s='State'}</label>
  71. <select name="id_state" id="id_state">
  72. <option value="">-</option>
  73. </select>
  74. <sup>*</sup>
  75. </p>
  76. {/if}
  77. <input type="hidden" name="alias" id="alias" value="{l s='My address'}">
  78. <input type="hidden" name="is_new_customer" id="is_new_customer" value="0">
  79. <!-- END Account -->
  80. </div>
  81. </fieldset>
  82. <fieldset class="account_creation dni">
  83.  
  84. <h3>{l s='Tax identification'}</h3>
  85.  
  86. <p class="required text">
  87. <label for="dni">{l s='Identification number'}</label>
  88. <input type="text" class="text" name="dni" id="dni" value="{if isset($smarty.post.dni)}{$smarty.post.dni}{/if}" />
  89. <span class="form_info">{l s='DNI / NIF / NIE'}</span>
  90. <sup>*</sup>
  91. </p>
  92. </fieldset>
  93. <p class="cart_navigation required submit">
  94. <span><sup>*</sup>{l s='Required field'}</span>
  95. <input type="submit" class="button" name="submitGuestAccount" id="submitGuestAccount" style="float:right" value="{l s='Continue'}">
  96. </p>
  97.  
  98. </form>
Go to the top of the page
+Quote Post
bostaf
post
Post #6





Grupa: Zarejestrowani
Postów: 374
Pomógł: 79
Dołączył: 6.04.2010
Skąd: Ostrów Wielkopolski

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


Literówka. Nie documet a document.
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 8.10.2025 - 12:54