The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> name box to new link, name box to new link
mrc333777
post Oct 23 2022, 08:12 AM
Post #1





Group: Members
Posts: 2
Joined: 23-October 22
Member No.: 28,603



<p align="center"><font size="5" color="#FF0000">SEARCH</font><br><br>

<font size="3">Enter Name To Search For</font>
<p align="center"><input type="text" id="page" />
<input type="submit" value="submit" onclick="goToPage();" /></a></p><br><br><br><br><br>
</p>

</html>

<script type="">
function goToPage() {
var page = document.getElementById('page').value;
window.location = "http://192.168.0.101/" + page + ".htm";
}
</script>

i have that above and it does most of what i want, but what do i need to add to make it remove the spaces from the name and then check to see if the link exists or not?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 23 2022, 02:12 PM
Post #2


.
********

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



QUOTE(mrc333777 @ Oct 23 2022, 03:12 PM) *

what do i need to add to make it remove the spaces from the name

You could use the trim() method: https://www.w3schools.com/jsref/jsref_trim_string.asp

QUOTE
and then check to see if the link exists or not?

I don't know any easy way to do that with javascript (besides trying to load the page, of course).

BTW it's invalid HTML to nest P element inside each other, always close one P before opening another.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 23 2022, 06:13 PM
Post #3


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



Actually, you don't need to close them since if you don't, the closing tag is implied. But if you do close them you need to do it right.

That said, I also think you *should* close paragraphs, but a validator won't mark it as an error if you don't. The validator will find quite a few errors with the way you've done it though. wink.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
mrc333777
post Oct 23 2022, 06:24 PM
Post #4





Group: Members
Posts: 2
Joined: 23-October 22
Member No.: 28,603



yea, i been adding bits and pieces of tutorials to an existing simple web site i made like 20-30 years ago.
i have no idea how to do html these days
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Oct 24 2022, 08:24 PM
Post #5


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



I've never done this myself but I think you could use Javascripts FileReader API to check if the file exists. At least it might be worth looking into.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

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

 



- Lo-Fi Version Time is now: 28th March 2024 - 04:56 AM