Script probleem

Gestart doorBjarnootjuh45 reacties192 weergaven

46 berichten · pagina 2 van 4

Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Alles werkt nu.

Ik wil nu alleen nog dit weten: Hoe doe je de maximaal aantal karakters in een textfield?

toevoeging op 1 maart 2012, 17:04:58:
Thommiee schreef:
Je kan dit ook veel mooier met jQuery maken..
Ik ken die taal niet maar ik ga de layout nog aanpassen. Dit is pas een begin.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Bjarnootjuh schreef:
Alles werkt nu.

Ik wil nu alleen nog dit weten: Hoe doe je de maximaal aantal karakters in een textfield?
max="10"

Volgensmij hoor.
0
Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoe kan ik dat in rode letters naast een form weergeven wat ze nog resterend hebben?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
$(function() {        
       $(#tweet).bind(keyup, function() {
            var maxchar = 140;
            var cnt = $(this).val().length;
            var remainingchar = maxchar - cnt;
            $(#twitter_message_count).html(remainingchar);
            if(remainingchar > 0){
                $(#twitter_message_count).css(color, green);
            }else{
                $(#twitter_message_count).css(color, red);
            }
        });
        
    });


Max length werkt niet. met dit jQuery scriptje kan je tekens tellen. Voor het gemak wordt het aantal rood gekleurd, als het de maximale lengte overschrijdt.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Aarclay schreef:
$(function() {        
       $(#tweet).bind(keyup, function() {
            var maxchar = 140;
            var cnt = $(this).val().length;
            var remainingchar = maxchar - cnt;
            $(#twitter_message_count).html(remainingchar);
            if(remainingchar > 0){
                $(#twitter_message_count).css(color, green);
            }else{
                $(#twitter_message_count).css(color, red);
            }
        });
        
    });
Max length werkt niet. met dit scriptje kan je tekens tellen. Voor het gemak wordt het aantal rood gekleurd, als het de maximale lengte overschrijdt.

Twitter?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Dat lees je goed.... Maar het gaat om het idee.
Dit trek ik ook maar uit mijn admin-backend.

Maak een aan met id = twitter_message_count, en een textarea met het id=tweet en je bent klaar.
Je kan de namen zelf aanpassen.
0
Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
maar ik moet dus
<form action="" method="POST">
 &nbsp;<textarea name="TextArea1" maxchar="100" style="width: 231px; height: 103px" cols="50"></textarea><br>
<input type="submit" name="verzenden" value="Bijwerken"> 
</form>


Hebben?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Aarclay schreef:
Dat lees je goed.... Maar het gaat om het idee.
Dit trek ik ook maar uit mijn admin-backend.
Is goed yummie
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Bjarnootjuh schreef:
maar ik moet dus
<form action="" method="POST">
 &nbsp;<textarea name="TextArea1" maxchar="100" style="width: 231px; height: 103px" cols="50"></textarea><br>
<input type="submit" name="verzenden" value="Bijwerken"> 
</form>
Hebben?

maxchar werkt niet.

$(function() {        
       $(#text).bind(keyup, function() {
            var maxchar = 140;
            var cnt = $(this).val().length;
            var remainingchar = maxchar - cnt;
            $(#count).html(remainingchar);
            if(remainingchar > 0){
                $(#count).css(color, green);
            }else{
                $(#count).css(color, red);
            }
        });
        
    });


Dit werkt wel (herschreven)...

geeft je textarea een id=text mee, en plaats een
0
Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dus:

[COLOR= #0000BB]<?php[/COLOR]
$[COLOR= #007700](function() {[/COLOR]        
       $[COLOR= #007700]([/COLOR][COLOR= #DD0000]#text[/COLOR][COLOR= #007700]).[/COLOR]bind[COLOR= #007700]([/COLOR][COLOR= #DD0000]keyup[/COLOR][COLOR= #007700], function() {
            var[/COLOR] maxchar [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]140[/COLOR][COLOR= #007700];
            var[/COLOR] cnt [COLOR= #007700]=[/COLOR] $[COLOR= #007700]([/COLOR]this[COLOR= #007700]).[/COLOR]val[COLOR= #007700]().[/COLOR]length[COLOR= #007700];
            var[/COLOR] remainingchar [COLOR= #007700]=[/COLOR] maxchar [COLOR= #007700]-[/COLOR] cnt[COLOR= #007700];[/COLOR]
            $[COLOR= #007700]([/COLOR][COLOR= #DD0000]#count[/COLOR][COLOR= #007700]).[/COLOR]html[COLOR= #007700]([/COLOR]remainingchar[COLOR= #007700]);[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR]remainingchar [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
                $[COLOR= #007700]([/COLOR][COLOR= #DD0000]#count[/COLOR][COLOR= #007700]).[/COLOR]css[COLOR= #007700]([/COLOR][COLOR= #DD0000]color[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]green[/COLOR][COLOR= #007700]);
            }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
                $[COLOR= #007700]([/COLOR][COLOR= #DD0000]#count[/COLOR][COLOR= #007700]).[/COLOR]css[COLOR= #007700]([/COLOR][COLOR= #DD0000]color[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]red[/COLOR][COLOR= #007700]);
            }
        });
        
    });[/COLOR]
?>


???

Ben ff de weg kwijt.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Bjarnootjuh schreef:
Dus:
[...]
???

Als je iets wilt vragen, vraag dat dan gewoon wink. We bijten heus niet.
0
Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zou je het ff in mijn script kunnen plaatsen:

[COLOR= #0000BB]<?php[/COLOR] 
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]verzenden[/COLOR][COLOR= #007700]])) 
  {[/COLOR] 
    [COLOR= #0000BB]$sVoornaam[/COLOR]        [COLOR= #007700]=[/COLOR]    [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]TextArea1[/COLOR][COLOR= #007700]]);[/COLOR] 
     
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO dias (content) VALUES ("[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$sVoornaam[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
 
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dia is succesvol bij de RDS geplaatst![/COLOR][COLOR= #007700]; 
  }[/COLOR] 
?> 
<form action="" method="POST">
 &nbsp;<textarea name="TextArea1" maxchar="100" style="width: 231px; height: 103px" cols="50"></textarea><br>
<input type="submit" name="verzenden" value="Bijwerken"> 
</form>

[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #007700]{

}[/COLOR]

?>
<br>
<br>
<br>
<iframe src="drop.php" border="false" width="100%" height="auto"></iframe>
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Haal die meta refresh van je pagina af en zet dit op de pagina waar je de data wilt laten zien:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function rds(){
$.get("http://djbjarn.nl/rds/rds.php", function(data){
$("#rds").html(data);
});

setTimeout("rds()",5000);
}
$(document).ready(function(){
rds();
});
</script>
<div id="rds"></div>
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
geeft je textarea een id=text mee, en plaats een
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bjarnootjuh schreef:
Dus:

[COLOR= #0000BB]<?php[/COLOR]
$[COLOR= #007700](function() {[/COLOR]        
       $[COLOR= #007700]([/COLOR][COLOR= #DD0000]#text[/COLOR][COLOR= #007700]).[/COLOR]bind[COLOR= #007700]([/COLOR][COLOR= #DD0000]keyup[/COLOR][COLOR= #007700], function() {
            var[/COLOR] maxchar [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]140[/COLOR][COLOR= #007700];
            var[/COLOR] cnt [COLOR= #007700]=[/COLOR] $[COLOR= #007700]([/COLOR]this[COLOR= #007700]).[/COLOR]val[COLOR= #007700]().[/COLOR]length[COLOR= #007700];
            var[/COLOR] remainingchar [COLOR= #007700]=[/COLOR] maxchar [COLOR= #007700]-[/COLOR] cnt[COLOR= #007700];[/COLOR]
            $[COLOR= #007700]([/COLOR][COLOR= #DD0000]#count[/COLOR][COLOR= #007700]).[/COLOR]html[COLOR= #007700]([/COLOR]remainingchar[COLOR= #007700]);[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR]remainingchar [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
                $[COLOR= #007700]([/COLOR][COLOR= #DD0000]#count[/COLOR][COLOR= #007700]).[/COLOR]css[COLOR= #007700]([/COLOR][COLOR= #DD0000]color[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]green[/COLOR][COLOR= #007700]);
            }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
                $[COLOR= #007700]([/COLOR][COLOR= #DD0000]#count[/COLOR][COLOR= #007700]).[/COLOR]css[COLOR= #007700]([/COLOR][COLOR= #DD0000]color[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]red[/COLOR][COLOR= #007700]);
            }
        });
        
    });[/COLOR]
?>
???

Ben ff de weg kwijt.

Je zet het tussen maar het is geen PHP emo
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren