Results 1 to 4 of 4

Thread: how to direct a user to a url using a user input

  1. #1
    Join Date
    Oct 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry how to direct a user to a url using a user input

    hi all

    im new to any kind of codeing and was wondering if any1 could help me out as this is a major part of my website.

    also im using a website creator (Wix) as i dont really know coding

    what im after doing is having a user input box that requires a reference number that i will be sending out with my products, when submitted i want it to take them to the relevant page e.g. my site is http://www.scotttaylor1989.wix.com/authenticproducts and say the reference number is 123456789 when submit is clicked i want it to take them to scotttaylor1989.wix.com/authenticproducts/123456789.

    on the other hand say 987654321 is NOT a reference number and they enter it and click submit i want an alert to pop up saying invalid reference number.

    below is what i have so far iv been searching the internet for days and cant find a solution (it might be the way im wording it)

    Code:
    <center><form name="RefChecker">
    
    Reference Number: <input type="text" placeholder="Enter Reference Number" name="ref" />
    
    <input type="submit" value="submit" onclick="gotoref()"/>
    
    </form></center>
    
    <script type="text/javascript">
    
    function gotoref()
    {
    
    }
    
    </script>
    any help would be much appreciated

  2. #2
    Join Date
    Oct 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    oh and another thing if someone is kind enough to supply me with the javascript for this can you put comments in the code so i know what does what if you cba then no worries i just want to try and learn the code instead of it being given

  3. #3
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    What you're describing seems to be something like this http://www.javascriptkit.com/script/cut34.shtml

    I have no idea about the website service you're using, as I suspect that many of the active members here dont either (we're more manual, build-it-yourself coders) so we probably won't be able to advise how or if you can "install" the script. It might give you a starting point though.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  4. #4
    Join Date
    Oct 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks i can only run html and javascript through it so need it to be pure html/javascript iv been looking around and it seems like every1 uses php all i need is basically a string with all the reference numbers in it, if someone enters a reference number thats in that string it should add / and the reference number to the end of www.scotttaylor1989.wix.com i just dont know how to add / and reference number to the current address im guessing something like
    Code:
    var website= www.scotttaylor1989.wix.com/authenticproducts
    var ref= 123456789, 123123123, 123412341
    so i need abit of javascript to check if the reference number is in var ref and if it is to add it to the end im guessing like this
    Code:
    var x= website + / + ref index 1
    i just dont understand how to check if the reference number is there and how to add all the pieces of the url together

    Basically i can only use html and javascript so is there a way to do this
    Last edited by jscheuer1; 10-27-2014 at 01:43 PM. Reason: format code

Similar Threads

  1. Set form value based on user input
    By Katt in forum JavaScript
    Replies: 2
    Last Post: 11-30-2010, 03:02 PM
  2. PHP user input validation
    By 4fit? in forum PHP
    Replies: 2
    Last Post: 09-20-2008, 12:14 PM
  3. How to create a link based on user input
    By dowens in forum Looking for such a script or service
    Replies: 1
    Last Post: 08-21-2007, 12:09 AM
  4. DD Tab Menu: Preserving User Input.
    By Codebunnie in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 03-17-2006, 04:41 PM
  5. Replies: 3
    Last Post: 09-23-2004, 03:40 PM

Bookmarks

Posting Permissions

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