Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Advanced php forms??

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Advanced php forms??

Postby jacquesy » Sun Feb 09, 2003 10:55 am

I want to create a form that when a yes or no option in a list element is selected the page automatically adds another option list next to with more options to pick.

This must work so that all of the cvalues entered previously into the form stay there.

In theory the form will refresh jsu tone part of the page introducing a new form element. I have seen this done on various other sites.

Thanks! :D :) :( :o :lol: 8) :? 8O :x :P :oops: :cry: :wink: :roll: :twisted: :evil: :!: :?: :idea: :arrow:
New php-forum User
New php-forum User
Posts: 12
Joined: Tue Jan 21, 2003 2:27 pm


Postby foot123 » Mon Feb 10, 2003 4:15 am

Show me where do you see the forms.
i don´t understand what you want to do. :?:
New php-forum User
New php-forum User
Posts: 14
Joined: Wed Nov 06, 2002 4:39 pm

Postby Hurkle » Tue Feb 11, 2003 9:42 am

I believe that if you want things like that to happen when you click on an option in a <SELECT> list, you have to use some type of client side scripting, i.e. vbscript, javascript. If using vbscript, it would be the 'onClick' event, or possibly the 'onSelect' event for the Select form element.

I don't use client side scripting of any kind anymore, and if I was doing this, and wanted this type of behavior, instead of a <SELECT> dropdown, I would use either an array of submit buttons, each with a different choice, or a bunch of hyperlinks, one per choice, each one passing the value for that id in the query string.

When I want to retain the values of an in progress form, I grab all the post and get values, and store them in an array. When I'm displaying the form, each element is either blank, or has a value. something like this..


if (isset($_POST['txt_user_name']))
$arr_form['txt_user_name'] = $_POST['txt_user_name'];
$arr_form['txt_user_name'] = "";


echo "<INPUT type = 'text' name = 'txt_user_name' value = '" ;
echo $arr_form['txt_user_name'];
echo "'>";

Code: Select all

I hope that makes sense, and helps you a bit.

New php-forum User
New php-forum User
Posts: 36
Joined: Tue Jan 07, 2003 8:45 am
Location: Minnesota, USA

Postby Joan Garnet » Tue Feb 11, 2003 4:23 pm

If you want to use client side scripting I suggest javascript, here you have a simple example:

Code: Select all
<script language=""javascript>
function add(){
   document.all.my_p.innerHTML += "<input type='submit' value=send2>"
<p id="my_p">
<input type="submit" onClick="add()" value="send1">
User avatar
Joan Garnet
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], kittykat and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.