copy link to in put form box whit link

Discussion in 'Javascript' started by Wouter, Feb 25, 2007.

  1. Wouter

    Wouter Guest

    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
    Wouter, Feb 25, 2007
    #1
    1. Advertising

  2. Wouter

    Danny Guest

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

    Danny
    Danny, Feb 25, 2007
    #2
    1. Advertising

  3. Wouter

    ASM Guest

    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

    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, Feb 26, 2007
    #3
  4. Wouter

    Wouter Guest


    > 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
    Wouter, Feb 26, 2007
    #4
  5. Wouter

    Evertjan. Guest

    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)
    Evertjan., Feb 26, 2007
    #5
  6. Wouter

    ASM Guest

    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.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>
    </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
    ASM, Feb 26, 2007
    #6
  7. Wouter

    ASM Guest

    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
    ASM, Feb 26, 2007
    #7
  8. Wouter

    Evertjan. Guest

    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)
    Evertjan., Feb 26, 2007
    #8
  9. Wouter

    Wouter Guest


    > 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
    Wouter, Feb 26, 2007
    #9
  10. Wouter

    ASM Guest

    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
    ASM, Feb 26, 2007
    #10
  11. Wouter

    ASM Guest

    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
    ASM, Feb 26, 2007
    #11
  12. Wouter

    Evertjan. Guest

    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)
    Evertjan., Feb 26, 2007
    #12
  13. Wouter

    Evertjan. Guest

    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)
    Evertjan., Feb 26, 2007
    #13
  14. Wouter

    ASM Guest

    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
    ASM, Feb 26, 2007
    #14
  15. Wouter

    ASM Guest

    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
    ASM, Feb 26, 2007
    #15
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Edison
    Replies:
    0
    Views:
    342
    Edison
    Oct 2, 2003
  2. VKTOP

    Problems whit JavaScript

    VKTOP, Feb 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    380
  3. Alex
    Replies:
    2
    Views:
    1,218
  4. Replies:
    26
    Views:
    2,106
    Roland Pibinger
    Sep 1, 2006
  5. news.wanadoo.nl

    how to deal whit vars in this form

    news.wanadoo.nl, Feb 19, 2006, in forum: Javascript
    Replies:
    1
    Views:
    103
Loading...

Share This Page