By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,496 Members | 1,528 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,496 IT Pros & Developers. It's quick & easy.

copy link to in put form box whit link

P: n/a
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

Feb 25 '07 #1
Share this Question
Share on Google+
14 Replies


P: n/a

I'm afraid I don't follow your query.

Danny
Feb 26 '07 #2

P: n/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[i].href)
A[i].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

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 26 '07 #3

P: n/a
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

Feb 26 '07 #4

P: n/a
Wouter wrote on 26 feb 2007 in comp.lang.javascript:
>
>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 ?
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 26 '07 #5

P: n/a
ASM
Wouter a écrit :
>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('....
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[i].href) {
A[i].onmouseover = function() {
document.myForm.img_url.value = this.href;
}
A[i].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>
</form>
P.S. sorry for my bad english
If you speak french it could be easier for me :-)
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 26 '07 #6

P: n/a
ASM
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 ?

:-)
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 26 '07 #7

P: n/a
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.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 26 '07 #8

P: n/a
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.
>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Groeten Wouter

Feb 26 '07 #9

P: n/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.

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 26 '07 #10

P: n/a
ASM
Evertjan. a écrit :
>
This is a multilingual NG,
perhaps but Dutch to French Yahoo! translator gives nonsense

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 26 '07 #11

P: n/a
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>
<http://en.wiktionary.org/wiki/meseems>
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/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 26 '07 #12

P: n/a
ASM wrote on 26 feb 2007 in comp.lang.javascript:
Evertjan. a écrit :
>>
This is a multilingual NG,

perhaps but Dutch to French Yahoo! translator gives nonsense
You surely expected that before testing?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 26 '07 #13

P: n/a
ASM
Evertjan. a écrit :
ASM wrote on 26 feb 2007 in comp.lang.javascript:
>Evertjan. a écrit :
>>This is a multilingual NG,
perhaps but Dutch to French Yahoo! translator gives nonsense

You surely expected that before testing?
Are you saying that it already was nonsense in Dutch ?
(not found another dutch<->french translator than Yahoo!)
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 26 '07 #14

P: n/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)

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 26 '07 #15

This discussion thread is closed

Replies have been disabled for this discussion.