"go to page" form with fill-in text box field

I

igor

I'm using FP2000 and my site is hosetd on a Linux Apache box. I am looking
to include on a page a form that allows the user to type, for example,
"green" in a text box and when he clicks on the submit button he is taken
to "green.htm" in the current folder. (If he types in a word that does not
have a corresponding page, then he'll get a 404.)

I have searched for script and form code that will do this. I found a
number of examples
(e.g., http://www.pagetutor.com/keeper/index.html)
but they all involve a pop-up (window or warning) that closes when submit
is clicked. I tried adapting them to just have the form on a regular,
sequential webpage, to no avail. Help would be appreciated. TIA. -- Igor
 
J

Jon Spivey

Hi,
The easiest way would probably be with javascript, eg
<form>
<input type="text" name="url">
<input type="button"
onclick="if(this.form.url.value)location.href=this.form.url.value;"
value="Go">
</form>
 
I

igor

Thanks. That works well, but be taken to abc.htm I have to enter "abc.htm"
and I'd like to be able to just enter "abc" and the code would append
".htm". What tweak do I need for that?

-- Igor


As a footnote: I was surprised that while you refer to your code as being
javascript, it does not have any script tags -- but it does work, at least
on my PC, as I have not yet posted it to the server (which happens to be
down). How is that?
 
J

Jon Spivey

OK, change this
onclick="if(this.form.url.value)location.href=this.form.url.value;"
to
onclick="if(this.form.url.value)location.href=this.form.url.value + '.htm';"
 
I

igor

Thanks. I tried your new code and it does not work (for me). To be sure
that I did not screw this up, here is a direct copy&paste:

<body>

<form>
<input type="text" name="url">
<input type="button"
onclick="if(this.form.url.value)location.href=this.form.url.value +
'.htm';"
value="Go">
</form>

</body>


When I run this on mainpage.htm and enter "test" in the text box, the only
response I get is in the browser adress bar: ".../mainpage.htm?url=test".
Any idea as to what might be missing?

-- Igor
 
J

Jon Spivey

Hi,
I just stuck a quick page up here
http://www.heresyourbook.com/formtest.htm

seems to work fine - obviosuly you'll get a 404 whatever you enter in the
box but you can see the browser is going to the right page.

--
Cheers,
Jon
Microsoft MVP


igor said:
Thanks. I tried your new code and it does not work (for me). To be sure
that I did not screw this up, here is a direct copy&paste:

<body>

<form>
<input type="text" name="url">
<input type="button"
onclick="if(this.form.url.value)location.href=this.form.url.value +
'.htm';"
value="Go">
</form>

</body>


When I run this on mainpage.htm and enter "test" in the text box, the only
response I get is in the browser adress bar: ".../mainpage.htm?url=test".
Any idea as to what might be missing?

-- Igor
 
I

igor

Thanks. This is very strange. I've tried the page at your site maybe 10
times on two PCs. 8 times it did not work -- i.e., I got
"formtest.htm?url=test". Twice I got 404 errors.

I tried IE6, NS7, Firefox 1.01.

So, I cleared all the caches and it started to work -- on you webiste and
mine. But, still intermittently. For example, I opened up NS 4.7. The
first two times it did not work (I had not opened NS4.7 yet today.) Then I
refreshed the page and it did work.

It is still entirely unpredictable to me as to when/why it will or won't
work.

Thanks for your help. I guess I'll have to look for something a bit more
"robust", though that is merely a hunch. -- Igor
 
I

igor

I think I found the "problem" -- If I hit the "enter" key, the code does
not work (or, does not work as I would like it to). I have to click on the
GO button. I don't know about you, but I think it is fairly common to use
ENTER rather than clicking on a submit button. So, do you happen to know
how to make ENTER work with this form? I tried the code shown at
http://www.cs.tut.fi/~jkorpela/forms/enter.html and it did not have any
effect on IE6 or NS (any flavor). Thanks. -- Igor
 
T

Trevor L.

Jon,

I have as similar query.

I have this code
<input type="button" value="1" onClick="chgImg('1')">
<input type="button" value="2" onClick="chgImg('2')">
<input type="button" value="3" onClick="chgImg('3')">
<input type="button" value="4" onClick="chgImg('4')">

There are about 60 such buttons (although I do generate then via JS so I
don't have to type the code for each one)

I would prefer to have a text box
Enter Number
|-------------|
|-------------|

Then the number in the box is placed into the function chgImg

Here is some code modified from some on w3schools

<form action="xxx.html" method="get">
Enter Number:
<input type="text" name="number" value=" ">
<br>
<input type="submit" value="Submit">
</form>

Apparently this calls xxx.html with parameter "number" set to what was typed
in, whereas I want to call a function

I tried altering the form tag to
<form action="chgImg(number)">

But it tried to open a file chgImg(number).

Can I do what I want or do I have to set up a file which then calls chgImg?

--
Cheers,
Trevor L.
Website: http://tandcl.homemail.com.au


I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html
 
S

Stefan B Rusynko

That's because the script is in the Go button field, but it is not a submit button
Change it from a normal button to a submit button (which triggers on Enter)

From
<input type="button" onclick="if(this.form.url.value)location.href=this.form.url.value + '.htm';" value="Go">
To
<input type="submit" onclick="if(this.form.url.value)location.href=this.form.url.value + '.htm';" value="Go">




|I think I found the "problem" -- If I hit the "enter" key, the code does
| not work (or, does not work as I would like it to). I have to click on the
| GO button. I don't know about you, but I think it is fairly common to use
| ENTER rather than clicking on a submit button. So, do you happen to know
| how to make ENTER work with this form? I tried the code shown at
| http://www.cs.tut.fi/~jkorpela/forms/enter.html and it did not have any
| effect on IE6 or NS (any flavor). Thanks. -- Igor
|
|
| >Hi,
| >I just stuck a quick page up here
| >http://www.heresyourbook.com/formtest.htm
| >
| >seems to work fine - obviosuly you'll get a 404 whatever you enter in the
| >box but you can see the browser is going to the right page.
|
 
I

igor

With your suggested edit, when I click on the button OR hit enter, I DO get
the same result ...but it is not the one I want -- i.e., they both produce
"...?url=test2" rather than passing test2.htm to bring it up in the
browser. (FWIW, I tested this locally on my PC, not from the server.)

I have come up with a work-around that does disable Enter when focus is in
the text box: I created the smallest possible 2nd text box elsewhere in the
form (1 char wide, 1px font) and hid it off to the side, and with more than
1 text box present Enter is disabled (unless the focus is on the button).
I would like to have Enter work, but this is OK.

If I'm still missing something or you have any additional ideas, pls let me
know. Thanks. -- Igor
 
T

Thomas A. Rowe

Why not just make the field a required field.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
S

Stefan B Rusynko

Or post your form code

--




| Why not just make the field a required field.
|
| --
| ==============================================
| Thomas A. Rowe (Microsoft MVP - FrontPage)
| WEBMASTER Resources(tm)
|
| FrontPage Resources, WebCircle, MS KB Quick Links, etc.
| ==============================================
| To assist you in getting the best answers for FrontPage support see:
| http://www.net-sites.com/sitebuilder/newsgroups.asp
|
| > With your suggested edit, when I click on the button OR hit enter, I DO get
| > the same result ...but it is not the one I want -- i.e., they both produce
| > "...?url=test2" rather than passing test2.htm to bring it up in the
| > browser. (FWIW, I tested this locally on my PC, not from the server.)
| >
| > I have come up with a work-around that does disable Enter when focus is in
| > the text box: I created the smallest possible 2nd text box elsewhere in the
| > form (1 char wide, 1px font) and hid it off to the side, and with more than
| > 1 text box present Enter is disabled (unless the focus is on the button).
| > I would like to have Enter work, but this is OK.
| >
| > If I'm still missing something or you have any additional ideas, pls let me
| > know. Thanks. -- Igor
| >
| >
| > On Fri, 1 Apr 2005 05:50:43 -0500, "Stefan B Rusynko"
| >
| >>That's because the script is in the Go button field, but it is not a submit button
| >>Change it from a normal button to a submit button (which triggers on Enter)
| >>
| >>From
| >><input type="button" onclick="if(this.form.url.value)location.href=this.form.url.value + '.htm';"
| >>value="Go">
| >>To
| >><input type="submit" onclick="if(this.form.url.value)location.href=this.form.url.value + '.htm';"
| >>value="Go">
| >>
| >>_____________________________________________
| >>SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >>"Warning - Using the F1 Key will not break anything!" (-;
| >>To find the best Newsgroup for FrontPage support see:
| >> http://www.net-sites.com/sitebuilder/newsgroups.asp
| >>_____________________________________________
| >>
| >>
| >>|I think I found the "problem" -- If I hit the "enter" key, the code does
| >>| not work (or, does not work as I would like it to). I have to click on the
| >>| GO button. I don't know about you, but I think it is fairly common to use
| >>| ENTER rather than clicking on a submit button. So, do you happen to know
| >>| how to make ENTER work with this form? I tried the code shown at
| >>| http://www.cs.tut.fi/~jkorpela/forms/enter.html and it did not have any
| >>| effect on IE6 or NS (any flavor). Thanks. -- Igor
| >>|
| >>|
| >>| >Hi,
| >>| >I just stuck a quick page up here
| >>| >http://www.heresyourbook.com/formtest.htm
| >>| >
| >>| >seems to work fine - obviosuly you'll get a 404 whatever you enter in the
| >>| >box but you can see the browser is going to the right page.
| >>|
| >>
| >
|
|
 
I

igor

Why not just make the field a required field.

I tried your suggestion and it does not work (for me). First, apparently
validation does not work with input type="button", only with "submit".
Second, even with "submit" it does not call up the target webpage, but
rather gives me "...?url=test2 Here is what I tried:

<form onsubmit="return FrontPage_Form1_Validator(this)"
name="FrontPage_Form1">
<!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE"
I-Minimum-Length="4" I-Maximum-Length="5" -->
<input type="text" name="url" size="6" maxlength="5">.
<p>
<input type="submit"
onclick="if(this.form.url.value)location.href=this.form.url.value +
this.form.url2.value + '.htm';" value="Click here to go proceed to the
Contact form" style="background-color: #000080; color: #FFFFFF;
font-family: arial; font-size: 14px">

Even so, validation is spotty, at best. I have gotten validation to work
when I have FP create an entire form for me, but not in this custom-made
form. The following code has two text boxes, "url" and "url2":

<form onsubmit="return FrontPage_Form1_Validator(this)"
name="FrontPage_Form1">
<!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE"
I-Minimum-Length="4" I-Maximum-Length="4" -->
<input type="text" name="url" size="6" maxlength="4">
<p><!--webbot bot="Validation" S-Data-Type="Number"
S-Number-Separators="x." B-Value-Required="TRUE" I-Minimum-Length="2"
I-Maximum-Length="2" --><input type="text" name="url2" size="2"
maxlength="2"></p>
<input type="submit"
onclick="if(this.form.url.value)location.href=this.form.url.value +
this.form.url2.value + '.htm';" value="Click here to go proceed to the
Contact form" style="background-color: #000080; color: #FFFFFF;
font-family: arial; font-size: 14px">

At webpage, If I enter correct data in field "url", for example ", but only
1 digit in "url2", when I clcik on the button I DO get a pop-up warning,
but when I cancel the warning I get the same response as if I had clicked
on the button.

This is a puzzle.
 
S

Stefan B Rusynko

You have an error in your form code (invalid If statement for onclick)

Explain why you are even using an If statement there
- to compare the fields values for url and url1?
And if so, then do what?

Explain again what your objective is




| On Fri, 1 Apr 2005 14:11:14 -0500, "Thomas A. Rowe" <[email protected]>
| wrote:
|
| >Why not just make the field a required field.
|
| I tried your suggestion and it does not work (for me). First, apparently
| validation does not work with input type="button", only with "submit".
| Second, even with "submit" it does not call up the target webpage, but
| rather gives me "...?url=test2 Here is what I tried:
|
| <form onsubmit="return FrontPage_Form1_Validator(this)"
| name="FrontPage_Form1">
| <!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE"
| I-Minimum-Length="4" I-Maximum-Length="5" -->
| <input type="text" name="url" size="6" maxlength="5">.
| <p>
| <input type="submit"
| onclick="if(this.form.url.value)location.href=this.form.url.value +
| this.form.url2.value + '.htm';" value="Click here to go proceed to the
| Contact form" style="background-color: #000080; color: #FFFFFF;
| font-family: arial; font-size: 14px">
|
| Even so, validation is spotty, at best. I have gotten validation to work
| when I have FP create an entire form for me, but not in this custom-made
| form. The following code has two text boxes, "url" and "url2":
|
| <form onsubmit="return FrontPage_Form1_Validator(this)"
| name="FrontPage_Form1">
| <!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE"
| I-Minimum-Length="4" I-Maximum-Length="4" -->
| <input type="text" name="url" size="6" maxlength="4">
| <p><!--webbot bot="Validation" S-Data-Type="Number"
| S-Number-Separators="x." B-Value-Required="TRUE" I-Minimum-Length="2"
| I-Maximum-Length="2" --><input type="text" name="url2" size="2"
| maxlength="2"></p>
| <input type="submit"
| onclick="if(this.form.url.value)location.href=this.form.url.value +
| this.form.url2.value + '.htm';" value="Click here to go proceed to the
| Contact form" style="background-color: #000080; color: #FFFFFF;
| font-family: arial; font-size: 14px">
|
| At webpage, If I enter correct data in field "url", for example ", but only
| 1 digit in "url2", when I clcik on the button I DO get a pop-up warning,
| but when I cancel the warning I get the same response as if I had clicked
| on the button.
|
| This is a puzzle.
|
 
T

Thomas A. Rowe

<form method="POST" action="Process.asp">
<p>URL 1: <!--webbot bot="Validation" S-Display-Name="URL" S-Data-Type="String"
S-Allow-Other-Chars="0123456789" B-Value-Required="TRUE" I-Minimum-Length="4"
I-Maximum-Length="4" --><input type="text" name="URL" size="6" maxlength="4"></p>
<p>URL 2: <!--webbot bot="Validation" S-Display-Name="URL2" S-Data-Type="String"
S-Allow-Other-Chars="0123456789" B-Value-Required="TRUE" I-Minimum-Length="2"
I-Maximum-Length="2" --><input type="text" name="URL2" size="3" maxlength="2"></p>
<p><input type="submit" value="Submit" name="B1">
</form>

You have to post the form to someplace to then put the value of the two fields together.

If you can use ASP or another server-side script, you do something like this on Process.asp:

<%
URL1 = Request.Form("URL1")
URL2 = Request.Form("URL2")
URL3 = ".htm"

If URL1 <> "" or URL2 <> "" Then
URL = URL1+URL2+URL3
Response.Redirect URL
Else
Response.Redirect "SendingPage.htm"
End If
%>

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
I

igor

Thanks. The first example does work ... but Enter does not generate a
submit -- just clears the text box. The second example also works and Enter
does what I want it to (= clicking on submit), but I'd want to eliminate
the **** for the PW field. I may give that a try -- Igor
 
I

igor

I have a lame explanation for the "if" statement -- it was in suggested
code I had found, I did not think it was doing harm, and I did not know how
to form the code w/o it.

My objective: Have a single text field into which a visitor to my site
enters a word. Clicking on the submit button OR hitting Enter causes the
code to add ".htm" to the word and forwards to the corresponding page.

In this thread, below, Ron offers an example of everything I need
www.rxs-enterprises.org/tests/jspass/
BUT the Enter key does not equal submit -- the text box is just cleared.

Thanks. -- Igor
 
R

Ronx

In the example the box that shows "*"s is a password box - replace it
with an ordinary text box
use <input type="text"
instead of <input type="password"

Pressing Enter will only clear the boxes if the entered text does not
point to a page. The Submit button has exactly the same action.

Note that the page may not work in FrontPage preview - it should be
tested using Preview in Browser.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top