Solved

Rowspan <td> and

Posted on 2013-12-15
21
242 Views
Last Modified: 2013-12-22
How do i make a td fill 2 rows here? Lets say the first (f_dag_navn) should have a "text"box around 2 lines (rows)? So i have 2 lines of text instead of 1.

I know have to stretch the height and Width of the "text"box using CSS, but it ofc. wont just gief me 2 lines.


while($record = $myData->fetch_object())
{
$form = <<<ENDFORM
<form action=admin.php method=post>
<tr>
<td><input type="text"  name="f_dag_navn"  value="$record->finale_dag_navn"/></td>
<td><input type="text"  name="f_deltager"  value="$record->finale_deltager"/></td>
<td><input type="text"  name="f_kval_res"  value="$record->finale_kval_res"/></td>
<td><input type=submit name="finale_tavle_opdater" value='Opdater' ></td>
<td><input type="hidden" name="f_dage" value="$record->finale_dage"/> </td>
</tr>
</form>
ENDFORM;
echo $form;
}

Open in new window

0
Comment
Question by:Mike Kristensen
  • 6
  • 5
  • 4
  • +5
21 Comments
 
LVL 9

Expert Comment

by:guswebb
ID: 39719955
Replace this...

<td><input type="text"  name="f_dag_navn"  value="$record->finale_dag_navn"/></td>

with this...

<td><input type="text"  rows="2" name="f_dag_navn"  value="$record->finale_dag_navn"/></td>
0
 
LVL 11

Expert Comment

by:Technodweeb
ID: 39719963
is this what you are wanting to do?

<td><textarea rows=2 cols=20 name="f_dag_navn"  value="$record->finale_dag_navn"/></td>
<td><textarea  rows=2 cols=20 name="f_deltager"  value="$record->finale_deltager"/></td>
<td><textarea  rows=2 cols=20 name="f_kval_res"  value="$record->finale_kval_res"/></td>
<td><input type=submit name="finale_tavle_opdater" value='Opdater' ></td>
<td><input type="hidden" name="f_dage" value="$record->finale_dage"/> </td>

Open in new window

0
 
LVL 9

Expert Comment

by:guswebb
ID: 39719973
By the way...having a td span two rows (of a table) is very different to having a textbox cater for two lines of text. Using <td rowspan="2">, which is how a td would be coded to span two rows, would not make any difference to the textbox within that table element.

Using rows="2" as an attribute of the textbox itself, as per my example above, is how you achieve what you are looking for.

As Technodweeb has also included in their code, you can also control the number of columns that the textbox has, thus controlling it's width before text wraps to a new line (not necessarily the same as the visible width which you will control using CSS).
0
 
LVL 11

Assisted Solution

by:Technodweeb
Technodweeb earned 200 total points
ID: 39719994
I am not going to say that the attribute "rows=2" will not work because it very well may but I will point out that it is not an attribute that is listed on the standards model for HTML. I have seen some browsers have attributes that are not standards based that do things that other browsers simply ignore.

Here is the standards reference for the HTML Input tag:
http://www.w3.org/wiki/HTML/Elements/input

I also tried to add this to a text field in Dreamweaver v13 (CC) and they do not list the attribute either. Adobe is closely tied to the W3C standards as well.

I went ahead and added it manually to the attribute of the Text field and go no visual results at all in Firefox, IE and Chrome.
0
 

Author Comment

by:Mike Kristensen
ID: 39720036
I cant make it Work....

I tried what you said and also tried this:
<td ><input type="textarea" rows="5" cols="5" style="width:250px;height:150px" name="_c16" placeholder="-" value="$record->c16" class="s_ansat_kiosk_g"/> </td>

Open in new window


I read the textarea was better for this. But this is what i see: The box is resized, but i just write in 1 line and it will keep going out of the box.
0
 
LVL 11

Expert Comment

by:Technodweeb
ID: 39720047
I did leave off one bit which was the </textarea> closing tag on my example.
You need to use the TextArea tag by itself. Do not use the Input tag also, they do not work together the way you have it. Take a look at my original post.
Untitled-1.fw.png
0
 
LVL 11

Expert Comment

by:Technodweeb
ID: 39720051
Actually I cannot edit my original post to add the closing tag properly so I am adding it here:

<td><textarea rows=2 cols=20 name="f_dag_navn">$record->finale_dag_navn</TextArea></td>
<td><textarea  rows=2 cols=20 name="f_deltager">$record->finale_deltager</TextArea></td>
<td><textarea  rows=2 cols=20 name="f_kval_res">$record->finale_kval_res</TextArea></td>
<td><input type=submit name="finale_tavle_opdater" value='Opdater' ></td>
<td><input type="hidden" name="f_dage" value="$record->finale_dage"/> </td>
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39720068
<input type="text" is valid.  And <textarea></textarea> is valid.  I have never seen <input type="textarea" anywhere.
http://www.w3schools.com/tags/tag_input.asp
0
 
LVL 9

Expert Comment

by:guswebb
ID: 39720075
Have you tried my original suggestion?

<td><input type="text"  rows="2" name="f_dag_navn"  value="$record->finale_dag_navn"/></td>
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39720132
rows="2" isn't valid.  You need to use <textarea> for more than one row.  If there are no spaces or other breaks in the text in the <textarea>, it won't wrap to a second row.  Using garbage text like that is not a useful example unless you are really expecting that.

And table tags don't work if you don't have the opening and closing <table></table> tags.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 9

Assisted Solution

by:guswebb
guswebb earned 100 total points
ID: 39720145
Ok....so this is what you need to test then....

while($record = $myData->fetch_object())
{
$form = <<<ENDFORM
<form action=admin.php method=post>
<tr>
<td><textarea rows="2" cols="20" name="f_dag_navn">$record->finale_dag_navn</TextArea></td>
<td><textarea  rows="2" cols="20" name="f_deltager">$record->finale_deltager</TextArea></td>
<td><textarea  rows="2" cols="20" name="f_kval_res">$record->finale_kval_res</TextArea></td>
<td><input type=submit name="finale_tavle_opdater" value='Opdater' ></td>
<td><input type="hidden" name="f_dage" value="$record->finale_dage"/> </td> 
</tr>
</form>
ENDFORM;
echo $form;
}

Open in new window


Type in more than 20 characters and make sure you have a space in there and it should wrap to the second line.
0
 
LVL 11

Expert Comment

by:Technodweeb
ID: 39720158
Yup, that works great... You nailed it...
0
 
LVL 14

Expert Comment

by:ThG
ID: 39720467
You need to use a <textarea> in combination with JavaScript to obtain an exact 2 rows field, here is an example, i'll let you adapt it to your situation (it should be straightforward, hint: the javascript code goes outside the loop!).

<html>
  <head><title>Test</title></head>
  <body>
    <script type="text/javascript">
      var keynum, lines = 1;

      function limitLines(obj, e) {
        // IE
        if(window.event) {
          keynum = e.keyCode;
        // Netscape/Firefox/Opera
        } else if(e.which) {
          keynum = e.which;
        }

        if(keynum == 13) {
          if(lines == obj.rows) {
            return false;
          }else{
            lines++;
          }
        }
      }
      </script>
    <textarea rows="2" onkeydown="return limitLines(this, event)"></textarea>
  </body>
</html>

Open in new window

0
 

Author Comment

by:Mike Kristensen
ID: 39720476
Oki thx all for your super answers. I used #Guswebb did, but changed the rows and cols and instead i used some CSS.

while($record = $myData->fetch_object())
{
$form = <<<ENDFORM
<form action=admin.php method=post>
<tr>
<td><textarea class="s_ansat_kiosk_g" maxlength="80" name="f_dag_navn">$record->finale_dag_navn</TextArea></td>
<td><textarea  class="s_ansat_kiosk_g" maxlength="80" name="f_deltager">$record->finale_deltager</TextArea></td>
<td><textarea  class="s_ansat_kiosk_g" maxlength="80" name="f_kval_res">$record->finale_kval_res</TextArea></td>
<td><input type=submit name="finale_tavle_opdater" value='Opdater' ></td>
<td><input type="hidden" name="f_dage" value="$record->finale_dage"/> </td> 
</tr>
</form>
ENDFORM;
echo $form;
} 

Open in new window


I tested on many browsers and platforms to be sure that it was a valid way to use it. But it seems the textarea Works in another way than input=text on how it will handle text.

#Guswebb
I tried
<td><input type="text"  rows="2" name="f_dag_navn"  value="$record->finale_dag_navn"/></td> 

Open in new window

but it wont make the text"box" 2 rows. It will just fill 2 rows, 1 being the input="text". . . But i havent tried it that much, because textarea just worked for me.
0
 
LVL 11

Assisted Solution

by:Technodweeb
Technodweeb earned 200 total points
ID: 39720490
So just to be clear... #Guswebb copied my answer and added it to the remaining lines of your initial post. You can award whomever you choose...
0
 
LVL 9

Expert Comment

by:guswebb
ID: 39720496
Give all the points to Technodweb...I'm not fussed by that. I was merely giving the OP the solution he wanted.
0
 

Author Comment

by:Mike Kristensen
ID: 39720497
:)
0
 

Author Comment

by:Mike Kristensen
ID: 39720502
I'm very happy for all the help, and ofc. i will ensure points are given correctly.

Again, i wanna thx for the help. It can be a struggle, mostly when you need the basic understanding. I started taking web dewelopment classes and i can start to help others aswell. Thats only cause of your help, that my motivation is kept high.
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39721216
Before you go ahead with that code in 'production', bear in mind that it's invalid!

You can't put the form tags outside of the TR.

There are a couple of ways to do what you need - you wrap the entire table inside 1 form, or you put each form inside it's own TD. The fact that you hve no submit button, I can't really say which is the best method (if you use one form, then you need to rename your fields)

Anything else will fail validation at best and simply ignore your form tags at worst.

Always run you page through validation!

http://validator.w3.org/
0
 
LVL 33

Assisted Solution

by:Slick812
Slick812 earned 200 total points
ID: 39722210
I Agree with ChrisStanyon 110%, , ,the browser TABLE HTML is very specific about proper setup and syntax, you are never suppose to have other HTML elements between any of the TABLE elements (<tr> or <td>) only INSIDE a TABLE <td> element can othere elements be used correctly
the <form> is a BLOCK element, same as a <div> and will knock out the table display from proper. so this should be avoided -

</tr>
<form action=admin.php method=post>
<tr>
0
 
LVL 33

Accepted Solution

by:
Slick812 earned 200 total points
ID: 39722259
maybe this will work better ?
while($record = $myData->fetch_object())
{
$form = <<<ENDFORM
<form action=admin.php method=post><table>
<tr>
<td><textarea class="s_ansat_kiosk_g" maxlength="80" name="f_dag_navn">$record->finale_dag_navn</TextArea></td>
<td><textarea  class="s_ansat_kiosk_g" maxlength="80" name="f_deltager">$record->finale_deltager</TextArea></td>
<td><textarea  class="s_ansat_kiosk_g" maxlength="80" name="f_kval_res">$record->finale_kval_res</TextArea></td>
<td><input type=submit name="finale_tavle_opdater" value='Opdater' ></td>
<td><input type="hidden" name="f_dage" value="$record->finale_dage"/> </td> 
</tr></table>
</form>
ENDFORM;
echo $form;
} 

Open in new window

of course you will have to take out the <table> thing before the  while($record
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now