LT   EN   RU  
2021 г. январь 17 д., - Информационный портал
  Компьютеры > Компьютерные технологии > Программирование > 
Lankomumo reitingas Версия для печати Версия для печати
Multiple Page Forms

So you have this long, involved form. Rather than present the user with a myriad of inputs on a single page, you want to break this up into separate form pages. So now you're asking, "How do you make multiple page forms?" I'm glad you asked. It's easy!

Here's one easy way. Consider the following small bit of code, which assumes that your form is submitted via the POST method:

  foreach($_POST as $key=>$value){
    if ($key!="submit"){
      echo "\t<input type=\"hidden\" name=\"$key\" value=\"$value\">

What's that bit of code do? If you were to place the above code between your opening <form> tag and the closing </form> tag, it will look at all values received from the prior page, strips out any HTML tags, replaces any character entities with their appropriate code and writes them to hidden inputs in the current form. It will skip a value of "submit" so it won't duplicate your submit button. If you name your submit button something other than "submit", you should change that bit in the code.

Here is a simple form that you can try out. First, look at the source code of this page. In particular, look at the <form> and confirm that there are no hidden inputs. The form simply submits back to this page. Type something in the box and click the submit button. It doesn't matter what you type, the value will simply be plugged into the resultant page as a hidden input in the form.


Now, after submitting the form, look at the source code again. Now you will notice that the value you typed in the input box is included as a hidden field in the form. Okay, let me insert a small disclaimer here. This is only an example to demonstrate a technique. If you look at the source code after submitting the form, you will notice that you have two inputs with the same name, one hidden and one visible. If you had submitted the form to a different page, with different inputs, that would not happen.


Lankomumo reitingas

Oбсудить на форуме - Oбсудить на форуме

Версия для печати - Версия для печати

Случайные теги:    Кормление (4)    Linux/Unix (5)    Любовь (32)    Сканеры (2)    Собаки (6)    Фильмы (10)    Стиль (5)    Кино (45)    Здаровья ребёнка (2)    Спорт (40)    Книги (2)    Еврейи (10)    Операционные системы (8)    Кулинария (39)    Медицина (84)    Авиация (2)    Буддизм (3)    Лов рыбы (11)    Набоков В. В. (94)    Животные (31)    Память (2)    Цветоводство (6)    Драконы (12)    Астрономия (10)    Компьютерные игры (26)    Астрология (13)    Фехтирования (6)    Политика (3)    Алкохольные напитки (29)    Накопители (2)    Мотоциклы (2)    НЛП (18)    Вирусы (25)    Археология (3)    Компьютеры (290)    Египет (5)    Скейборды (2)    Саентология (10)    Литература (4)    Комплектующие (18)    Развлечения (26)    Биология (34)    Шахматы (2)    Поэты (3)    Садоводство (12)    Образование (101)    Физкультура (3)    Воспитания (3)    Кошки (11)    Экология (18)