By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,848 Members | 1,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,848 IT Pros & Developers. It's quick & easy.

For loop containing HTML

P: 74
I am trying to write a form loop that displays a text box however many times the user wants. For example, if the user enters 4, 4 text boxes will show up.

Here is the code I have now for the for loop:

Expand|Select|Wrap|Line Numbers
  1. for($i = 1; $i <= $elements; $i++)
  2. {
  3.         print "Enter number $i: <br>";
  4.         print "<input type="text">";
  5. }
  6.  
I get this error:

Bareword found where operator expected at assignment4.pl line 127, near ""(displays a textbox here)"" syntax error at assignment4.pl line 127, near ""(displays a textbox here)

Thanks in advance!
Feb 14 '08 #1
Share this Question
Share on Google+
4 Replies


KevinADC
Expert 2.5K+
P: 4,059
can't have double-quotes in a double-quoted string:
Expand|Select|Wrap|Line Numbers
  1. print "<input type="text">";
you have to escape them:

Expand|Select|Wrap|Line Numbers
  1. print "<input type=\"text\">";
better yet use the qq{} operator with your double-quoted strings:

Expand|Select|Wrap|Line Numbers
  1. print qq{<input type="text">};
or q{} since what you really have is a single-quoted construct:

Expand|Select|Wrap|Line Numbers
  1. print q{<input type="text">}; 
Feb 14 '08 #2

P: 74
can't have double-quotes in a double-quoted string:
Expand|Select|Wrap|Line Numbers
  1. print "<input type="text">";
you have to escape them:

Expand|Select|Wrap|Line Numbers
  1. print "<input type=\"text\">";
better yet use the qq{} operator with your double-quoted strings:

Expand|Select|Wrap|Line Numbers
  1. print qq{<input type="text">};
or q{} since what you really have is a single-quoted construct:

Expand|Select|Wrap|Line Numbers
  1. print q{<input type="text">}; 
It worked. Thank you!
Feb 14 '08 #3

eWish
Expert 100+
P: 971
I was to slow......


--Kevin
Feb 14 '08 #4

KevinADC
Expert 2.5K+
P: 4,059
I was to slow......


--Kevin

and you weren't fast enough either ;)
Feb 14 '08 #5

Post your reply

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