473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

If condition under dropdown

ddtpmyra
333 100+
Hi I need some help to learn how to do my dynamic dropdown. Basically on my dropdown I have value Others and when the user select this I want to display another text box beside it. Below is my codes but it didn't work I wonder where it went wrong.


Dropdown Menu:
Expand|Select|Wrap|Line Numbers
  1. echo "
  2. <tr><td width='100%'><b>Generated By:</b></td>"; 
  3. $res=mysql_query("select Generated_By  from tblGeneratedBy"); 
  4. if(mysql_num_rows($res)==0){ 
  5. echo "there is no data in table.."; 
  6. } else { 
  7. echo '
  8. <td width="100%"><select name="GeneratedBy" id="GeneratedBy" value=\"$GeneratedBy\">'; 
  9. for($i=0;$i<mysql_num_rows($res);$i++) { 
  10. $row=mysql_fetch_assoc($res); 
  11. echo"<option value=\"$row[Generated_By]\" "; 
  12. if($GeneratedBy==$row[Generated_By]) 
  13. echo "selected"; 
  14. echo ">$row[Generated_By]</option>"; 
  15. }
  16. if $row[Generated_By]== ('Others') {
  17.  echo "<input type='text' >";  else 
  18. }echo 
  19. "</select><br></tr></td>"; 
  20. }     
  21.  
Mar 17 '09 #1
1 3313
TheServant
1,168 Expert 1GB
What didn't work? Please be more specific with the problem. Did the whole dropdown box not work or just your input box? Anyway, three things:
Line 17: you should be self closing your input tags ( <input /> not <input> ).
Line 17: You have not closed your if( ){ } statement before you have else.
Line 18: You have closed the previous if statement instead of opening the else statment.

Regards.
Mar 17 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
0
by: Toonman | last post by:
I have a webpage with a <form> consisting of a large table grid of dropdown lists used to make changes in a database. Some of these dropdown lists have the same value. I'm trying to make it so...
1
by: son | last post by:
i need some help with my database i'v got a qyery with a field orderdate from a table orders with a condition date, when a user opens a rapport from this query a popupbox is asking for the date of...
13
by: melih.onvural | last post by:
Group, I'm having a tough time understanding some of the previous posts on this topic so I wanted to write what I've tried and hope that you can help me troubleshoot. I have a dropdown populated...
5
by: Gil | last post by:
Is there a way to tell if a combbox is in dropdown mode. I tried and if statement combobox.dropdown = true but i get an error. dropwndown function doesnt store if its true or false what i am...
3
by: devNorway | last post by:
I have been struggling with a problem for days now, and searched for related problems and solutions but had no luck. I have two dropdown listboxes where the first is populated in page load and...
0
by: Kay | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp...
0
by: Kay O'Keeffe | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp...
6
by: fran7 | last post by:
Hi, Would anyone know how to populate an asp dropdown with a dependant condition. I need this dropdown to select only artists, ie from the authortwo field where in another field, ie extrathree, ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.