Nieuw lid |
|
form:
<form action="matchverslag.php" method="post">
<table>
<tr>
<td>Match: <br /></td>
<td><input type="text" name="match" size="30" maxlength="30" value="Thuisploeg - Uitploeg"/> <br /></td>
</tr>
<tr>
<td>Uitslag: <br /></td>
<td><input type="text" name="uitslag" size="5" maxlength="5" value="0-0"/> <br /></td>
</tr>
<tr>
<td></td>
<td><input type="button" value="B" onClick="tag(form.tekst, 'b', '');"></td>
</tr>
<tr>
<td>Matchverslag: <br /></td>
<td><textarea name="tekst" cols="65" rows="10" id="tekst"></textarea></td>
</tr>
<td> <br /></td>
<td><input name="match_id" type="hidden" id="match_id" value="<? echo $_GET[id];?>">
<input type="submit" name="submit" value="Verstuur" /></td>
</tr>
</table>
</form>
<form action="matchverslag.php" method="post"> <table> <tr> <td>Match: <br /></td> <td><input type="text" name="match" size="30" maxlength="30" value="Thuisploeg - Uitploeg"/> <br /></td> </tr> <tr> <td>Uitslag: <br /></td> <td><input type="text" name="uitslag" size="5" maxlength="5" value="0-0"/> <br /></td> </tr> <tr> <td></td> <td><input type="button" value="B" onClick="tag(form.tekst, 'b', '');"></td> </tr> <tr> <td>Matchverslag: <br /></td> <td><textarea name="tekst" cols="65" rows="10" id="tekst"></textarea></td> </tr> <td> <br /></td> <td><input name="match_id" type="hidden" id="match_id" value="<? echo $_GET[id];?>"> <input type="submit" name="submit" value="Verstuur" /></td> </tr> </table> </form>
Hier staat de button B in die <b> </b> in de textarea gaat steken via het volgende script:
<script>
function tag(veld, tag1, tag2)
{
if (!tag2)
{
tag2 = tag1;
}
if (document.selection)
{
veld.focus();
var selection = document.selection.createRange();
if(selection.text)
{
selection.text = "["+tag1+"]"+selection.text+"[/"+tag2+"]";
}
else
{
veld.value += "["+tag1+"] [/"+tag2+"]";
}
}
else if (veld.selectionStart || veld.selectionStart == '0')
{
var startPos = veld.selectionStart;
var endPos = veld.selectionEnd;
if (startPos != endPos)
{
veld.value = veld.value.substring(0, startPos)
+ "["+tag1+"]"
+ veld.value.substring(startPos, endPos)
+ "[/"+tag2+"]"
+ veld.value.substring(endPos, veld.value.length);
}
else
{
veld.value = veld.value.substring(0, startPos)
+ "["+tag1+"] [/"+tag2+"]"
+ veld.value.substring(endPos, veld.value.length);
}
}
}
</script>
<script>
function tag(veld, tag1, tag2)
{
if (!tag2)
{
tag2 = tag1;
}
if (document.selection)
{
veld.focus();
var selection = document.selection.createRange();
if(selection.text)
{
selection.text = "["+tag1+"]"+selection.text+"[/"+tag2+"]";
}
else
{
veld.value += "["+tag1+"] [/"+tag2+"]";
}
}
else if (veld.selectionStart || veld.selectionStart == '0')
{
var startPos = veld.selectionStart;
var endPos = veld.selectionEnd;
if (startPos != endPos)
{
veld.value = veld.value.substring(0, startPos)
+ "["+tag1+"]"
+ veld.value.substring(startPos, endPos)
+ "[/"+tag2+"]"
+ veld.value.substring(endPos, veld.value.length);
}
else
{
veld.value = veld.value.substring(0, startPos)
+ "["+tag1+"] [/"+tag2+"]"
+ veld.value.substring(endPos, veld.value.length);
}
}
}
</script>
Dit is dus de oplossing voor de button.
de oplossing om de enters automatisch in de database in te voegen zonder dat de gebruiker <br /> na elke lijn moet typen is de volgende:
$text = nl2br($_POST['tekst']);
$text = nl2br($_POST['tekst']);
voila! |