copy link to in put form box whit link

W

Wouter

Hi,

I try to make the follow. I want that i can click on a text link and that
then a link wil be copyed in a input form box (<input type="text"
name="img_url" />).

I have google-ed about how i can make this but i cant find a explane how i
can do this. I'm sure my javascript skills are the problem....

Is there here someone who can help me whit this ?

Greets Wouter
 
A

ASM

Wouter a écrit :
I try to make the follow. I want that i can click on a text link and that
then a link wil be copyed in a input form box (<input type="text"
name="img_url" />).

Do not understand the interest
Ordinary when you click a link a new file is called
What will be the use of this "copy" if the new file is loaded as soon
I have google-ed about how i can make this but i cant find a explane how i
can do this. I'm sure my javascript skills are the problem....

<script type="text/javascript">
onload = function() {
var A = document.getElementsByTagName('A');
for(var i=0; i<A.length; i++)
if(A.href)
A.onclick = function() { copi(this); }
}
function copi(what) {
document.myForm.img_url.value = what.href;
return false;
}
</script>
<form name="myForm">
<input name="img_url">
</form>
<a href="javascript:alert('hello')">hello</a>
<a href="page.htm">page</a>
<a name="myAnchor"></a>


and no link no more works
 
W

Wouter

and no link no more works

The solution that i see now is. whit PHP because thats the only script
langauge i can script. So can i use PHP to strip the url ? So i dont so
anymore javascript:alert('....

I try to use somewhere if(isset($img_url)){ but i think i can't use the
var...

is it possible what i want. Or is there a better solution whit javascript ?

Greets Wouter

P.S. sorry for my bad english
 
E

Evertjan.

Wouter wrote on 26 feb 2007 in comp.lang.javascript:
The solution that i see now is. whit PHP because thats the only script
langauge i can script. So can i use PHP to strip the url ? So i dont
so anymore javascript:alert('....

I try to use somewhere if(isset($img_url)){ but i think i can't use
the var...

is it possible what i want. Or is there a better solution whit
javascript ?

Beste Wouter,

PHP is een serverside taal, dus draait op de server voordat de html
stroom naar de client browser wordt verzonden, en kan dus geen actieve
dingen doen in de browser.

javascript:alert('....

is een onderdeel ven clientside scripting, en draait op de browser in de
machine van de gebruiker.

Als je een vraag stelt in deze NG, dan moet je toch wel wat javascript
willen studeren.
I try to make the follow. I want that i can click on a text link and
that then a link wil be copyed in a input form box (<input type="text"
name="img_url" />).

de / hierboven is alleen voor XML, niet gebruiken dus in HTML.

Bedoel je gewoon een <a href=''>...</a>?
En die moet dan natuurlijk niet uitgevoerd worden, anders is de pagina
weg. Een link kan je niet copieren, alleen zijn url.

Probeer dit eens:

=================== test.html =============

<script type='text/javascript'>
function toonInInput(x) {
document.getElementById('a').value = x.href;
return false; // om het uitvoeren van de link te voorkomen.
};
</script>

<input type="text" name='a' id='a'>
<br>
<a href='http://cnn.com/'
onclick= 'return toonInInput(this)'>
CNN</a>
<br>
<a href='http://google.com/'
onclick= 'return toonInInput(this)'>
Google</a>

===========================================
P.S. sorry for my bad english

Tja, je vraag werd er niet erg duidelijk van.
Vraag het voortaan [ook] in het Nederlands.
 
A

ASM

Wouter a écrit :
The solution that i see now is. whit PHP because thats the only script
langauge i can script. So can i use PHP to strip the url ? So i dont so
anymore javascript:alert('....

in my proposition
javascript:alert()
was an example of link
I try to use somewhere if(isset($img_url)){ but i think i can't use the
var...

I do not understand what exactly you try to get or to do ...
- If user clicks on one link
the form will not be send, and by the fact no 'img_url' to give to php
- if user clicks on a link, once the file is loaded
the href of the link is clearly seen in browser's address bar
- what is the goal for this input 'img_url' ?
- how do you expect to send the form on each click on a link ?
is it possible what i want. Or is there a better solution whit javascript ?

to answer to your question "copy link in an input" try that :

<html>
<script type="text/javascript">
onload = function() {
var A = document.getElementsByTagName('A');
for(var i=0; i<A.length; i++)
if(A.href) {
A.onmouseover = function() {
document.myForm.img_url.value = this.href;
}
A.onclick = function() {
var o = document.myForm.img_url;
o.value = escape(o.value);
document.myForm.submit();
return false;
}
}
}
</script>
<form name="myForm">
<input name="img_url" size=70>
</form>
<a href="javascript:alert('hello')">hello</a>
<a href="page.htm">page</a>
<a name="myAnchor"></a>
<a href="page.php?go=somewhere">other where</a>
</html>


To use with the form in php alone

soluce 1:
=========
<form action="linker.php">
<p>go to :<br>
<input type=radio value="page1.php" name="img_url"> page 1<br>
<input type=radio value="page2.php" name="img_url"> page 2<br>
<input type=radio value="page3.php" name="img_url"> page 3<br>
<input type=radio value="page4.php" name="img_url"> page 4<br>
<p><input type=submit value=GO>
</form>


soluce 2:
=========
<form action="linker.php">
<p>go to : <select name="img_url">
<option value="page1.php"> page 1</option>
<option value="page2.php"> page 2</option>
<option value="page3.php"> page 3</option>
<option value="page4.php"> page 4</option>
</select>
<input type=submit value=GO>
P.S. sorry for my bad english

If you speak french it could be easier for me :)
 
E

Evertjan.

ASM wrote on 26 feb 2007 in comp.lang.javascript:
Evertjan. a écrit :
Wouter wrote on 26 feb 2007 in comp.lang.javascript:
P.S. sorry for my bad english

Vraag het voortaan [ook] in het Nederlands.

Et en français ?

:)

Naturellement, mon cher Stéphane, et en Swahili et Sranan Tongo.

:) :) :)

This is a multilingual NG,
and threads where the OP gets into trouble with English,
can easily go on in the OP's language, meseems.
 
W

Wouter

PHP is een serverside taal, dus draait op de server voordat de html
stroom naar de client browser wordt verzonden, en kan dus geen actieve
dingen doen in de browser.

javascript:alert('....

is een onderdeel ven clientside scripting, en draait op de browser in de
machine van de gebruiker.

ik geloof dat ik vanmorgen niet meer helemaal wakker was. Ik had daar even
niet bij nagedacht. (nachtdienst gehad)
Als je een vraag stelt in deze NG, dan moet je toch wel wat javascript
willen studeren.

Ik ben bezig op javascript te leren. Ben alleen nog even opzoek naar een
goed boek. De boeken die ik tot op heden heb gezien of van de bieb heb
geleend spraken me niet echt aan. Daar bij komt dat ik op 1 of andere manier
javascript erg lastig vind! Maar het is wel erg handig....

Probeer dit eens:

inderdaad dat doet precies wat ik zoek!
P.S. sorry for my bad english

Tja, je vraag werd er niet erg duidelijk van.
Vraag het voortaan [ook] in het Nederlands.

Ik ging er vanuit dat het een engelse groep was. Vandaar mijn poging tot het
engels.

Groeten Wouter
 
A

ASM

Evertjan. a écrit :
Vraag het voortaan [ook] in het Nederlands.
ASM wrote on 26 feb 2007 in comp.lang.javascript:
Et en français ?

:)

Naturellement, mon cher Stéphane, et en Swahili et Sranan Tongo.

:) :) :)

Ho oui! Oh oui! en Sranan Tongo
This is a multilingual NG,
and threads where the OP gets into trouble with English,
can easily go on in the OP's language, meseems.

meseems ? = me seems ?

However I would be glad to know what you're telling.
May be I have something to learn ?
At least, something to light the question.
 
E

Evertjan.

ASM wrote on 26 feb 2007 in comp.lang.javascript:
Evertjan. a écrit :
Vraag het voortaan [ook] in het Nederlands.
ASM wrote on 26 feb 2007 in comp.lang.javascript:
Et en français ?

:)

Naturellement, mon cher Stéphane, et en Swahili et Sranan Tongo.

:) :) :)

Ho oui! Oh oui! en Sranan Tongo
This is a multilingual NG,
and threads where the OP gets into trouble with English,
can easily go on in the OP's language, meseems.

meseems ? = me seems ?

[methinks meseems is deprecated]
<http://en.wiktionary.org/wiki/methinks>
However I would be glad to know what you're telling.

I suppose the international parts of my text
[HTML/XML/NG/browser/clientside/etc.]
with my code speak for themselves.

And, if a conversation is in French, also many are left out.
May be I have something to learn ?
At least, something to light the question.

Perhaps we can learn Sranan Tongo together?
It is [also] spoken in Amsterdam.
<http://www.sil.org/americas/suriname/Sranan/Sranan.htm>
<http://en.wikipedia.org/wiki/Sranan_Tongo>
<http://www.websters-online-dictionary.org/definition/Sranan-english/>
 
E

Evertjan.

ASM wrote on 26 feb 2007 in comp.lang.javascript:
Evertjan. a écrit :

perhaps but Dutch to French Yahoo! translator gives nonsense

You surely expected that before testing?
 
A

ASM

Evertjan. a écrit :
ASM wrote on 26 feb 2007 in comp.lang.javascript:


You surely expected that before testing?

Are you saying that it already was nonsense in Dutch ?


(not found another dutch<->french translator than Yahoo!)
 
A

ASM

Evertjan. a écrit :
ASM wrote on 26 feb 2007 in comp.lang.javascript:
However I would be glad to know what you're telling.

I suppose the international parts of my text
[HTML/XML/NG/browser/clientside/etc.]
with my code speak for themselves.

as your code was very close to mine
I don't know more what you told him nor what he expected.
And, if a conversation is in French, also many are left out.

I try to do not use french
and if, I give a small idea in english too
(if we can call english what I write)
Perhaps we can learn Sranan Tongo together?

No no no thank you, english is enough hard and difficult for me.
But we could try chtimi :)
(spoken only in far north of France, closer to Amsterdam than my town)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top