Jump to content

[SOLVED] Form


s1yman

Recommended Posts

Hi,

 

I was wondering if it is possible to have a form where boxes change based on other fields.

 

What I mean exactly is;

If you have a form, each entry point will have two radio buttons one for "text" and the one for "picutre"

If the text button is selected it will display a "text" box and if the other is selected it will display a "file" box (upload box).

 

Does anyone know if this is possible and how I might go about writing a script for it?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/119986-solved-form/
Share on other sites

Having a bit of trouble retrieving the information once on the second form.

 

First form;

<form id="form1" name="form1" method="post" action="form2.php">
  <input name="div0" type="radio" value="file" id="1div0" />
  <label for="1div0">Image</label>
  <input name="div0" type="radio" value="text" id="2div0" />
  <label for="2div0">Text</label></html>

 

Second form;

<?php
$zero = $_GET['div0'];
{
print '<form id="form2" name="form2" method="post" action="form2pro.php">';
print '<input name="div0" type="';
print $zero;
print '" value="" />';
print '<input type="submit" value="submit" /></form>';
}
?>

 

Any ideas what I'm doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/119986-solved-form/#findComment-618556
Share on other sites

i can see right off the bat, you have named both your input's the same, "div0".  if you are trying to create an array, you must add '[]' to the name .. only then can you have the same name for each input.

<input name="div0[]" value="something">

 

as well, you form is using "POST", and you are trying to retrieve the data via $_GET .. this will not work as $_GET gathers it's values from the URL, ex. form.php?id=something&name=Peter, etc...

Link to comment
https://forums.phpfreaks.com/topic/119986-solved-form/#findComment-618566
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.