Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a script

Status
Not open for further replies.

Khanjan

Programmer
Feb 24, 2004
41
0
0
NL
Hi,

I am developing a website where i need a javascript script, but i never worked with javascript. I hope someone can help me.


After clicking a button, a prompt window should be visible.
In this prompt window , one should put the URL of an image, juist like it works in some Forums. AFter clicking on OK, the url should appear in a textarea between the <IMG src = "IMAGE URL" </IMG>

The same idea, you can see in some Forums, where you can give the image url and in your post you can see the image.


Please help, i need the CODE, because i can not write javascript in my own.

Thanx in advance,
 
If you want everyone to be able to see the image, you'll have to use a server-side process like ASP or PHP to save the url to a file or database. Then, use the server-side process to create the page that will display the image.

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
No no, I juist want that users put their image url in the prompt window, and the same url should be visible after clickin OK in a textarea. No image showing, nothing else.

I have been able to do this:


<input type="button" onClick="set()" value="Open window">

function set(){
name = window.prompt("your Photo Link is ","http:// ")
document.write("<IMG src = "+name+" </IMG>")

}

Doing this, i get the picture on my webpage, BUT, i dont want to see the picture,i juist want to get the IMAGE URL and put that URL in a TEXTAREA between these tags
<IMG src = "URL" </IMG>

HOW SHOULD I DO THIS?????
 
Ok, I think I understand. Do you mean something like this?
Code:
<script language="JavaScript">
function set(){
  var name=window.prompt("your Photo Link is ","http:// ")
  document.myForm.myTextarea.value+='<img src="'+name+'">';
}
</script>
Code:
<form name="myForm">
<input type="button" onclick="set()" value="Open window">
<textarea name="myTextarea"></textarea>
</form>

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Adam, if I understand him correctly, Khanjan is asking for something that will DISPLAY the picture once the user inputs the URL.

This worked for me in IE6.0 (adapted from Adam's code, above):

Code:
<html>
<head>
<script language="JavaScript">
function set(){
  var name=window.prompt("your Photo Link is ","http:// ")
  document.myForm.myImage.src = name;
}
</script>
</head>
<body>
<form name="myForm">
<input type="button" onclick="set()" value="Choose Picture">
<img name="myImage" src=""/>
</form>
</body>
</html>

The downside is that if no source is given immediately, that infuriating little-red-x appears on the page.

To avoid the little-red-x, you can also do this:
Code:
<html>
<head>
<script language="JavaScript">
function set(){
  var name=window.prompt("your Photo Link is ","http:// ")
  myImage.innerHTML = "<img src='"+name+"' />";
}
</script>
</head>
<body>
<form name="myForm">
<input type="button" onclick="set()" value="Choose picture">
<a name='myImage'></a>
</form>
</body>
</html>

Be careful of entering URL's with quotes in them, however. They tend to #(*@$& things up.

Have a good weekend!

--Dave
 
Thanx guys,

adam0101 Your code helped alot, that was wat i wanted to know. Thanx again.

LookingForInfo thank you too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top