0

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

3
Contributors
7
Replies
9
Views
7 Years
Discussion Span
Last Post by colweb
0

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

0

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.

0

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

0

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>
0

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

Edited by AkhJ: n/a

0

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

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.