简体   繁体   中英

A form with jQuery UI tabs, PHP and a back function

I've read several posts, but seem to have a problem in understanding...

  • In one of the tabs I've got a form -- ok
  • This form will be server validated with php -- ok
  • If no errors occur - the user has the possiblities to finally send the form -- ok
  • New function: If no errors occur - the user has also the possibility to go back and change entries -- not ok

First I tried something like

echo '<input type="button" class="submit" value="make changes" name="back_button" onClick="history.go(-1)">';

Will go to the wrong tab and clears the form in the correct tab...

The form values are "sticky" like

<input id="email" name="email" type="text" value="<?php if (isset($email)){echo $email;} ?>" /> 

which did work for now.

The form is in the 5th. tab which I can address with something like that: $tabs.tabs('select', 4);

How should my JS code look and were should I include it in my php-file and how do I bind it to my "back-button"?

Update: On the final page the user can see the entered values and decide to send them finally or go back and change them. But the go back part is not working.

Update 2:

<form method="post" action="team.php#tabs-sign_in">

Update 3:

Sorry for confusing: Will go to the wrong tab and does not clear the form in the correct tab... which is okay. The data is still there but the user will see the wrong tab.

Update 4:

Just came up with something like that, which won't work...

<a href="#" onClick='history.go(-1);$("#tabs").tabs("select","4");'>modify</a>

Can anyone explain me why this won't work?

I think you may find using sessions useful. Save the data to a session for future editing.

http://php.net/manual/en/features.sessions.php

Or if you have a user login mechanism, it may be better to save the form state in your database to be edited / updated at a later date.

Why don't you use javascript to store most of your client side data and manipulation. And use ajax to post the data to your server, so you don't need to page refresh, and your back and forward between tab would not need a page loading, nor need a history

edit Switch between tab would mean show and hide different preloaded div's

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM