tags:

views:

39

answers:

2

http://img175.imageshack.us/img175/4295/tableissue.png

Here's the picture to begin with.

I have this check box, that when you check, then with jQuery toggle(); it hides that you see in first half of the picture (#writeComment) and shows #SCtryVOTE (what you see in the other half picture, to the right).

Now i dont know why but of some reason it expands when its checked, why i dont know, is it because it needs more place than it have or? how do i make this work without having problems when its checked.

Here's coding:

$('#tryout').click(function () {

    $('#writeComment').toggle(!$(this).attr('checked'));

    $('#SCtryVOTE').toggle($(this).attr('checked'));
});

the js jquery script part, heres the table and divs HTML part:

<input type="checkbox" id="tryout">
<table  align="center" width="400" cellpadding="0" cellspacing="1" id="theBoxer">
<tr style="background: #686868;">
<td align="center" valign="top" width="70" height="25" style="border:1px #FFF solid;">Opret</td>
<td align="center" valign="top" width="70" height="25" style="border:1px #FFF solid;">Opret</td>
</td>
</tr>
<tr>
<td align="left" valign="top" width="70" height="112" style="">
TEST
</td>
<td align="left" valign="top" width="70" height="112" style="">
<div id="writeComment">
Smid en kommentar:<br>
<form action="javascript:DoInsert()" method="post">
<textarea id="kommentar" name="kommentar"></textarea><br />
<input type="hidden" name="fID" id="fID" value="<? echo $_GET["id"]; ?>">
<input type="submit" name="Submit" value="Sæt ind!"> 
</form>
</div>

<div id="SCtryVOTE"  style="display: none;">
<form onsubmit="if (!this.comment.cleared) clearContents( document.getElementById('comment') ); return true;" action="javascript:DoSCInsert()" method="post">
<textarea onfocus=" javascript:clearContents(this); this.cleared=true;" rows="5" cols="40" id="comment" name="comment" <?php if($vis["username"] == $pusername) { echo "DISABLED"; } ?>>Tryk for at skrive. Skal være detaljeret og grundet.</textarea>
<br>Ja: <input type="radio" value="Y" id="SCvoteY" name="vote"></input>  Nej: <input type="radio" id="SCvoteN" value="N" name="vote"> </input>
<input type="submit" id="SCstem" name="Submit" value="Stem!"> 
</form>
</div>

Maybe you need the CSS part too for these two boxes:

#writeComment{
position: relative;
left: 5px; 
top: 10px;
}
#SCtryVOTE{
position: relative;
left: 5px; 
top: 10px;
}
+1  A: 

I believe the problem is that the <textarea> in the first form does not specify any size and the textarea in the seconf one does specify rows="" and cols="".

Also, the increased vertical offset might be due to how you hide the first form. Can you post that script code as well?

Franci Penov
the rows and cols made the solution, thank you!
Karem
A: 

since we cant format comments

re: @Franci Penov Cant see where i should do this, which part dont you understand of the coding and i will try to explain the best i can – Azzyh 1 min ago

for example, Which one makes it easier to see the extra </td>?

unindented (original code)

<table  align="center" width="400" cellpadding="0" cellspacing="1" id="theBoxer">
<tr style="background: #686868;">
<td align="center" valign="top" width="70" height="25" style="border:1px #FFF solid;">Opret</td>
<td align="center" valign="top" width="70" height="25" style="border:1px #FFF solid;">Opret</td>
</td>
</tr>

indented

<table  align="center" width="400" cellpadding="0" cellspacing="1" id="theBoxer">
    <tr style="background: #686868;">
        <td align="center" valign="top" width="70" height="25" style="border:1px #FFF solid;">
            Opret
        </td>
        <td align="center" valign="top" width="70" height="25" style="border:1px #FFF solid;">
            Opret
        </td>
        </td>
    </tr>
BioBuckyBall
Thank you, the thing is i dont know how to do these spaces while writing the code, i use notepad++, so i always thought that its such sorted up because other programs does it for you, no?
Karem
usually other programs do it for you. But you can do it manually as well, as long as your keyboard has a Space key. :-)
Franci Penov
Yeah it is nicer when your tool does it for you, but if it doesn't, you should do it (for your own sanity really). Next is the spaces vs tabs decision :)
BioBuckyBall