473,395 Members | 1,554 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,395 software developers and data experts.

Select list that causes an input text box to appear

Hello, extreme newbie here...

I am trying to create a drop-down menu (select input type), and based on which of the options the user selects (Yes or No), an input text box appears for the user to enter their member number. Unless the user selects "Yes" from the menu, this box shouldn't appear.

I have tried two options -- using javascript within my php file (onSelect) and a simple if statement (with no javascript) basically saying if variableyes/no = "yes" echo the input box.

Here is the latter code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     if ($PDGA_Is =="Yes")
  3.     echo "<input type='text' size='10' name='$PDGA_No' value='$fields['PDGA_No']' />";
  4.     ?>
  5.  
This is bringing up a Parse error code ("syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING"). Even if the syntax was correct, I doubt this is the right way to code this type of function. Is there a way for the select menu to trigger the text box without the user having to press a button or perform any other action than selecting "Yes" from the menu?

Thx
DH
Oct 25 '07 #1
2 2066
Atli
5,058 Expert 4TB
Hi DH. Welcome to TSDN!

The problem is with the value of the input box you are echoing.
You can put normal variables straight into a double-quoted string without any problems, but array elements must be inside brackets.

Expand|Select|Wrap|Line Numbers
  1. # This is ok
  2. $str = "hello my name is $name";
  3.  
  4. # This is not
  5. $str = "Hello my name is $myArr['name']";
  6.  
  7. # It should be
  8. $str = "Hello my name is {$myArr['name']}";
  9.  
  10. # or
  11. $str = "Hello my name is $myArr[name]";
  12.  
Oct 25 '07 #2
Markus
6,050 Expert 4TB
Hi DH. Welcome to TSDN!

The problem is with the value of the input box you are echoing.
You can put normal variables straight into a double-quoted string without any problems, but array elements must be inside brackets.

Expand|Select|Wrap|Line Numbers
  1. # This is ok
  2. $str = "hello my name is $name";
  3.  
  4. # This is not
  5. $str = "Hello my name is $myArr['name']";
  6.  
  7. # It should be
  8. $str = "Hello my name is {$myArr['name']}";
  9.  
  10. # or
  11. $str = "Hello my name is $myArr[name]";
  12.  
Ahhhh.

That helps me a bunch :)
Oct 25 '07 #3

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

Similar topics

23
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've...
3
by: J. Muenchbourg | last post by:
I have an ASP admin script where I'm adding records, and I have a category that already has set name values hard-coded into a selct option pulldown, but if the user wants to create a new category...
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
6
by: calfliu | last post by:
hello: everybody! I have a simple question. How can I translate the selected value from art to recipient(hidden input button)? <form name="send" method="post" action="send.cgi"> <select...
4
by: Marek Mänd | last post by:
This seems an IE issue only: 4253 bytes testcase: http://www.hot.ee/idaliiga/testcases/ieselect/bnlinkingselectinmsie.htm Can one have 1) a mouseover/mouseout element on TBODY 2) change in...
16
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on...
0
by: =?Utf-8?B?am8uZWw=?= | last post by:
Hello All, I am developing an Input Methop (IM) for PocketPC / Windows Mobile (PPC/WM). On some devices the IM will not start. The IM appears in the IM-List but when it is selected from the...
4
by: rn5a | last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5 options are shown at any given time) allows multiple selection whereas the 2nd one allows only 1 option to be selected at a time. ...
3
by: matwilko | last post by:
hi, i am trying to create a simple version of itunes...and i am using iframes to do this. I have already set up the iframes using dreamweaver and used a drop-down menu to select the genre. When...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.