Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Textbox.value create Link

    Hi all.

    I'm pretty new at scripting in general, and wonder if anyone could help me with something i'm trying to achief.

    I have an .html page, that contains several textboxes. Their values are dynamic, since they are being called from a server.

    One of these textboxes containes a relative url (displayed as text).
    Next to it i have an onclick-button.

    What i'm searching for is a script for the onclick-button, to launch the textbox.value as URL.

    Textboxname : Textboxfield
    Onlick-button name : Launchlink

    Ex.:

    Textbox displays the value: document/start.pdf
    Clicking the button will launch the relative hyperlink document/start.pdf

    I don't think this can be to hard to achieve, but trying out some scripts i found on the net made me realize i'm far from being an expert in these things.

    Thanks in advance for any help

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Try this kinda:
    PHP Code:
    <form>
    <
    input name="Textboxfield" type="text" value="document/start.pdf"><br>
    <
    input name="Launchlink" type="button" value="Launch link" onclick="location.href=this.form.elements['Textboxfield'].value">
    </
    form
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks already for your very fast reply. The only thing is, the textboxfield value is variable.

    So the document/start.pdf was just an example. This value changes together with some other fields depending on a users' selection.

    Is there any way to make the textboxfield.value in your script variable?

    (by the way, it should run in html... is there any chance you could change it into a javascript code?)

    Regards & many thanks in advance

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    But it is variable. If user will insert another URL in textbox, the button will open the new input value (even I think this is not your intention). Could you detail your problem, please?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Look, this is the piece of code on my page that generates the textboxfield:

    </SPAN><TEXTAREA class=MsoTextbox id=textboxfield style="LEFT: 1.125in; WIDTH: 154px; POSITION: absolute; TOP: 0.792in; HEIGHT: 17px" tabIndex=18 name=txtlink rows=1 MsoTextAlign="General"></TEXTAREA>

    The whole page has been designed in microsoft access (maybe that's why the code looks so wierd heh).

    This represents the code of the button to click on:

    </SUP><BUTTON id=Command0
    style="Z-INDEX: 1; LEFT: 2.917in; WIDTH: 1in; POSITION: absolute; TOP: 0.75in; HEIGHT: 0.25in"
    tabIndex=19 name=formname MsoTextAlign="General">Command0</BUTTON>


    Now, i don't know how to add your code to both of these in order to make it work to be honest heh..

    Could you help me out maybe?

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Something like:

    <BUTTON id=Command0
    style="Z-INDEX: 1; LEFT: 2.917in; WIDTH: 1in; POSITION: absolute; TOP: 0.75in; HEIGHT: 0.25in"
    tabIndex=19 name=formname MsoTextAlign="General" onclick="location.href=document.getElementById('textboxfield').value">Command0</BUTTON>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #7
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey Kor, thanks again for your help.

    Well the code you just gave me worked, if i gave the textbox an absolute value, like this:

    </SPAN><TEXTAREA class=MsoTextbox id=textboxfield style="LEFT: 1.125in; WIDTH: 154px; POSITION: absolute; TOP: 0.792in; HEIGHT: 17px" tabIndex=18 name=txtlink rows=1 MsoTextAlign="General">www.codingforums.com</TEXTAREA>

    When i leave it blank (as it originaly was), it loads something, but it goes so fast i can't see what it loads, and then it gives a "page cannot be found"-error.

    Could it be there's also a piece of code needed for the textbox-part? Or maybe something is overlooked?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •