Hello All,

Greetings of the day!

I am new to PHP & working on a project. What my senior had asked to do is to , creat a drop down menu. I did the same. And just below of drop down menu there is a Text Box, where user can write there queries. Now what they want is that, user must have to select a category otherwise he/she should not be able to write in the box below.

like this :-

<select name="field" id="field" size="1">
          <option>--------Select Field--------</option>
          <option>Theatre</option>
          <option>Painting</option>
          <option>Dance</option>
          <option>Architecture/Sculpture</option>
                                </select>

<textarea name="query" cols="50" rows="5" id="query" lang="MUST" title="Query" > </textarea>


Now it should be a must for user to select a category then only he/she would be able to write in the box below.

Please help me in this regard.


Thanks & Regards

Use javascript on the onchange even of the html (the dropdown)

The javascript must a function that tests if the user selected something other than null and if the user did, then the text box should appear (change the css display from none to block)

google for the exact code to put for testing the dropdown selected value or text ..etc and test what was selected..

Like "theigost" already said, use javascript. No need to use php here. Maybe the following will help you further:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
	<form>
		<select name="field" id="field" size="1" onchange="form.tfield.style.visibility='visible'">
	    	<option>Select field</option>
	        <option>Theatre</option>
	        <option>Painting</option>
	        <option>Dance</option>
	    </select>
	    <input type="text" name"tfield" id="tfield" style="visibility:hidden">
	</form>
</body>
</html>

There is no testing here is anything useful is selected, but the text box will only appear if something is selected.

Hello ColWeb,

You helped me in this regard. But now i have another problem :(

<td height="104"><strong>Your Question</strong></td>
        <td><textarea name="query" cols="50" rows="5" id="query" lang="MUST" title="Query" > </textarea></td>
      </tr>
      <tr>
        <td height="45">&nbsp;</td>
        <td><br>          <input type="submit" name="Submit" value="Submit" /></td>

This is what i have been using to create Text Box. But when i apply your code, it just creates another small box.

Please help me to do the same with the original box size.

Thanks & Regards

If I do the following, I get a select box and after making a selection get a textarea. All within a table.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>Untitled</title>
</head>
<body>
	<form>
	<table border="1">
	<tr>
		<td>
			<select name="field" id="field" size="1" onchange="form.query.style.visibility='visible'">
				<option>Select field</option>
				<option>Theatre</option>
				<option>Painting</option>
				<option>Dance</option>
			</select>
		</td>
		<td>
			<textarea name="query" cols="50" rows="5" id="query" lang="MUST" title="Query" style="visibility:hidden"> </textarea>
		</td>
	</tr>
	<tr>
		<td colspan="2" align="center">
			<input type="submit" name="Submit" value="Submit" />
		</td>
	</tr>
	</table>
	</form>
</body>
</html>

Thanks a Ton Colweb for your immediate response :). I feel really good here. And i wish if i could help people around here.


Thanks & Regards

Thanks a Ton Colweb for your immediate response :). I feel really good here. And i wish if i could help people around here.


Thanks & Regards

That's easy :) stick around and see the forums every once in a while

Thanks a Ton Colweb for your immediate response :). I feel really good here. And i wish if i could help people around here.


Thanks & Regards

Could you please mark this thread as solved. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.