Give help. Get help.

  • asp
    # November 8, 2009 at 3:04 pm


    I’m making a sort of simple news system, but I’m stuck with a problem. I’m trying to add an image URL to a textfield when you click an image. But I can’t get it to work. I have tried to find any kind of plugin ore already fabricated code, but can’t find anything that works.

    Do some of you know how to do this? I’ll be very happy if someone have the answer to the question. ;)

    # November 10, 2009 at 3:14 pm

    Can you show some code?

    # November 10, 2009 at 3:45 pm

    This is how the php displays the URL’s that can be chosen. The point is that when the user clicks on the image the jquery adds the files_URL to a regular text box.

    while($row = mysql_fetch_array($result))
    echo ‘<div class="row" id="’ . $row .’">’;
    echo ‘<h5>’ . $row . ‘ ‘ . $row . ‘ ‘ . $row . ‘ kb’;
    echo ‘<a href="#"><img id="add" src="/Bilder/legg_til.png" /></a><a id="URL" href="/nyheter’ . $row . ‘">Prewiev</a></h5>’;
    echo ‘</div>’;

    I also tryed to make somthing with jQuery

    $(document).redy(function() {
    var url = document.getElementById("URL").value;
    $("#add").click( function() {

    This dident work 8-)

    I also found somthing at the internet

    function ChgText()
    var MyElement = document.getElementById("MyTextBox");
    MyElement.value = "If you see this, it worked!";

    return true;

    I got this to work, but not when trying to implement it with the php stuff.

    I hope this helps :D

    # November 16, 2009 at 11:28 am

    This effect is easy with jQuery.

    Here’s a working example

    And you can see the code here

    I’ve added a few comments to the jQuery, but if you want me to explain in more detail just ask. ;)

    # November 16, 2009 at 3:58 pm

    Nice :D
    It seems to be what I’m looking for, but just to be on the safe side…

    This works with php to right?

    My idea was to add a URL to the txtfield, but then I need to add the value of the URL. And if that is going to be the value of the button it will be quite long :? Ore am I missing somthing?

    So is it possible to have a value of the button that says “add url” and then the button adds a url that the php generates.

    The code you presented was brilliant but because I’m not that good with jquery I need some help from a pro. ;)

    # November 16, 2009 at 4:19 pm

    Okay, here’s an update.

    // View the demo

    // View the demo’s code

    I only changed two things.
    1.) The button now has the attribute ‘value’ (e.g. value=";)
    2.) jQuery now looks for the attribute ‘value’ in the button clicked

    The PHP to create the buttons for links will look like this

    < ?php while( $row = mysql_fetch_assoc($res) ) { // Obviously you'll change this accordingly to your database echo '
    # November 17, 2009 at 11:40 am

    Nice :D

    Thank you, I got it to work.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.