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. ;)
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.
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. ;)
I only changed two things. 1.) The button now has the attribute 'value' (e.g. value="http://some-url.com") 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 '<button value=\"' . $row['url'] . '\">' . $row['title'] . '</button>';
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. ;)
while($row = mysql_fetch_array($result))
{
echo '<div class="row" id="' . $row['filer_ID'] .'">';
echo '<h5>' . $row['filer_navn'] . ' ' . $row['filer_realnavn'] . ' ' . $row['filer_str'] . ' kb';
echo '<a href="#"><img id="add" src="/Bilder/legg_til.png" /></a><a id="URL" href="/nyheter' . $row['files_URL'] . '">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() {
$("#textbox").append(url);
});
});
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
Here's a working example
http://jsbin.com/uvuve3
And you can see the code here
http://jsbin.com/uvuve3/edit
I've added a few comments to the jQuery, but if you want me to explain in more detail just ask. ;)
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. ;)
// View the demo
http://jsbin.com/unose
// View the demo's code
http://jsbin.com/unose/edit
I only changed two things.
1.) The button now has the attribute 'value' (e.g. value="http://some-url.com")
2.) jQuery now looks for the attribute 'value' in the button clicked
The PHP to create the buttons for links will look like this
Thank you, I got it to work.