Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > copy link to in put form box whit link

Reply
Thread Tools

copy link to in put form box whit link

 
 
Wouter
Guest
Posts: n/a
 
      02-25-2007
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



 
Reply With Quote
 
 
 
 
Danny
Guest
Posts: n/a
 
      02-25-2007

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

Danny
 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      02-26-2007
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
 
Reply With Quote
 
Wouter
Guest
Posts: n/a
 
      02-26-2007

> 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



 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      02-26-2007
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)
 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      02-26-2007
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
 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      02-26-2007
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
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      02-26-2007
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)
 
Reply With Quote
 
Wouter
Guest
Posts: n/a
 
      02-26-2007

> 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



 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      02-26-2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to deal whit vars in this form news.wanadoo.nl Javascript 1 02-20-2006 10:37 AM
Dinamyc and static nat whit only one public ip address? mckennan Cisco 2 08-28-2005 03:28 PM
cisco 1721 triangle whit 2 cisco 800 over isdn 128k Himselff Cisco 4 06-27-2005 12:42 PM
Using line con 0 whit analog modem on Cisco 837 beagly Cisco 1 12-02-2004 12:46 PM
How Read Database whit datos in Format RTF Edison ASP .Net 0 10-02-2003 08:51 AM



Advertisments