Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.