The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> use number to choose url
dmr1712
post Mar 24 2020, 04:15 PM
Post #1





Group: Members
Posts: 1
Joined: 24-March 20
Member No.: 27,248



Hello everyone,

I am new to this place and (sort of) new to client side programming. I'll first tell you want I want to achieve and what I did up untill now (besides googling my *ss off).

I want to make a very simple page. On this page there needs to be a form where one can type a number (sometimes with a letter as well). Depending on which number is submitted, an url must be chosen and the page needs to go to that url.

To make it visual:

type 1 to go to url.com/1
type 2 to go to url.com/2
type 3b to go to url.com/chapter2/3b
type 224b to go to url.com/book3/chapter4/224b
etc etc

as you see, there are different 'base' urls. At first I did not see this and i created a form with a GET function to simply add a number to an url. As you can see, that didnt work so well for all urls.

I have an (excel) list of all urls and (in another row) all the numbers that should refer to those numbers.

Is there any way to use clientside scripting to get this done? If not, what would be an (easy) way to do this?

Thank you so much for any pointers you could give me.

Sincerely,
DMR1712
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 24 2020, 04:58 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



QUOTE(dmr1712 @ Mar 24 2020, 10:15 PM) *

Is there any way to use clientside scripting to get this done? If not, what would be an (easy) way to do this?

You can do it with javascript, but then anybody can view the number/url pairs in the HTML source. If you want the data to be secret it's better to use a server-side script instead (like PHP).

The basic programming might be the same in either case. If there are just a few number/url pairs it might be simplest to use a chain of IF/ELSE conditions. If the list is long, maybe an array is more efficient (though I recall associative arrays are easier to use in PHP than in javascript, and I'm not sure of how to do it with an ordinary array). If the list is really long maybe a database could be used along with a server-side script?
User is online!PM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 01:54 PM