View Full Version : how to direct a user to a url using a user input

10-25-2014, 03:02 PM
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)

<center><form name="RefChecker">

Reference Number: <input type="text" placeholder="Enter Reference Number" name="ref" />

<input type="submit" value="submit" onclick="gotoref()"/>


<script type="text/javascript">

function gotoref()



any help would be much appreciated ;)

10-25-2014, 04:29 PM
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

10-26-2014, 10:01 AM
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.

10-26-2014, 11:06 AM
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

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

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