Jump to content

codefossa

Members
  • Posts

    583
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by codefossa

  1. Driver.php needs to be a string in the load function. But what I was saying is that you ain't passing the value, so you may as well make it a button or link. What I posted doesn't refresh to load, but you have to use another page to get the data. JS can't interact with your database, it can only call on a PHP script to make it execute and it can show the results.

  2. $.load() uses a string. You don't seem to close your option tags. Lastly, you didn't tell us what the problem is, or what errors you may be getting if you even have error reporting on.

     

    Also, what's the point of the options when you're using $.load() without any GET parameters? You're probably better off with $.post() for this since you probably don't want people just linking to the actions.

     

    Here's an example that you may be able to go off of.

    Demo Page: http://xaotique.no-ip.org/tmp/36/

     

    HTML

    <select id="driver">
    <?php
    
    for ($i = 1; $i < 6; $i++)
    	echo '<option value="' . $i . '">' . $i . '</option>' . "\n";
    
    ?>
    </select>
    
    <div id="content2"></div>

     

    Javascript / jQuery

    $(document).ready(function()
    {
    $("#driver").change(function()
    {
    	$.post('', { opt: $(this).val() }, function(data)
    	{
    		$("#content2").html(data);
    	});
    });
    });

     

    PHP

    <?php
    
    if ($_SERVER['REQUEST_METHOD'] == "POST")
    {
    echo "<pre>", print_r($_POST), "</pre>";
    die();
    }
    
    ?>

  3. It does work, but you didn't include jQuery.

    The example he gave: http://xaotique.no-ip.org/tmp/35/

     

    Add the jQuery include in the HEAD.

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

     

    You should also wrap your JS in a load trigger function. In jQuery, you can just use $.ready().

     

    $(document).ready(function()
    {
    $("body").addClass("has-js");
    });

  4. Is your font monospaced? If not, you can only estimate what would be close. As Andy said, this should be done in PHP because it's pointless to send a bunch of data you don't need.

     

    Maybe try something like this.

     

    <?php
    
    function word_limit($string, $limit)
    {
    $arr = preg_split('/\s+/', $string);
    return implode(' ', array_splice($arr, 0, $limit));
    }
    
    $str = "One two three four five.  Six seven eight nine ten, eleven twelve.  Thirteen!!!  Fourteen (:";
    
    // Output: One two three four five.  Six seven eight nine ten, eleven twelve.
    echo word_limit($str, 12);
    
    ?>

  5. You would check both. If you wanted to look for someone named James Howard, you could do ..

     

    `firstname` = 'James' AND `surname` = 'Howard'

     

    To search from the keyword, you would change the = '' to LIKE '%{$keyword}%' like you're doing. You just have to compare both, you don't choose two fields at the same time for comparing.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.