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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Javascript pre-filled URL form field

    Hi All,

    I wonder if someone might be able to help me fix a small problem I'm having. It's probably quite a basic fix, but I am no coder!

    I have recently built a proofing section on my photography website, where clients can view and submit their selections after I have completed a shoot for them.

    Essentially, after each job, I send them a link to their particular set of proofs, where they can log in with their client ref and password.

    I am trying to make a 'portal' page, where there is a simple form field, into which they can enter the last part of the link and be forwarded on to their proofs.

    The idea is that the form field is 'pre-filled' with the first part of the URL (www.jkenny.co.uk/proofing/.…..) and they simply input the last part of their link, click go, and then are taken to their individual log in area.

    I've almost got it working, but when they click 'Go', the link has '?URL=' added on to it… I'm not sure why this is happening, and I can't see a way to fix it.

    The page the form is on is located at Online Proofing - James Kenny Photography and below is the code I've used to make the form. Can anyone see where I'm going wrong?

    ---------------------

    <script type="text/javascript">// <![CDATA[
    function convertURL() { document.go.url.value = document.go.url.value.replace( /\s/g, ""); var url = document.getElementsByName( "url")[0]; var fullurl = document.getElementsByName( "fullurl")[0]; fullurl.value = "http://www.jkenny.co.uk/proofing/"+ url.value;
    // ]]></script>

    <form name="go" onsubmit="convertURL();location.href=url.value;return false">
    <h2 style="text-align: center;"></h2>
    <h2 style="text-align: center;"></h2>
    <p style="text-align: center;">Welcome to the online proofing portal. To continue to your login page, please complete the URL below using the details provided to you. If you have not yet received your login information, please get in touch.</p>


    <span style="color: #ffffff;">.</span>


    <h2 style="text-align: center;"></h2>
    <h1 style="text-align: center;"><span style="color: #c0c0c0;">www.jkenny.co.uk/proofing/</span><input type="text" name="url" /></h1>





    <p style="text-align: center;"><input type="submit" value="Proceed to Login" /></p>
    <span style="color: #ffffff;">.</span>

    </form>

    ------------------------

    Thanks in advance!

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,989
    Thanks
    56
    Thanked 557 Times in 554 Posts
    I don't understand why you're submitting the form if all you want to do is redirect the page. Can't you just do this:
    Code:
    <body>  
    <script type="text/javascript">
    function convertURL(frm) { 
    location.href = "http://www.jkenny.co.uk/proofing/"+ frm.url.value;
    }
    </script>
    <form name="go" >
    <h1 style="text-align: center;"><span style="color: #c0c0c0;">www.jkenny.co.uk/proofing/</span><input type="text" name="url" /></h1>
    <p style="text-align: center;"><input type="button" onclick="convertURL(this.form)"; value="Proceed to Login" /></p>
    </form>
    </body>
    ?

  • Users who have thanked xelawho for this post:

    nufc_kenny (03-21-2014)

  • #3
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks very much! I got a PM from a member called 'low tech' and he also sent me a fix. Tried to reply to his PM but wouldn't send for some reason :\

    Thanks again to both of you!


  •  

    Posting Permissions

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