473,413 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

append textbox value to href link before submit

Hi

I have a page with a form and a textbox.
before to submit the form I want to chek if the inserted value in the
textbox is already present in a database.
So I need to pass the textbox value by a javascript link to another
page to check.
my code is
<a href="javascript:location.href='page_check.php' "Go check </a>
and this work and open page_check.php

but when I want to append the textbox value, the code not work. I know
I make mistake

<a href="javascript:location.href='page_check.php?Box =' +
document.formName.textboxName.value "Go check </a>

Any suggest ?
Regards
Jul 8 '08 #1
10 21478
pt36 wrote:
Hi

I have a page with a form and a textbox.
before to submit the form I want to chek if the inserted value in the
textbox is already present in a database.
So I need to pass the textbox value by a javascript link to another
page to check.
my code is
<a href="javascript:location.href='page_check.php' "Go check </a>
and this work and open page_check.php

but when I want to append the textbox value, the code not work. I know
I make mistake

<a href="javascript:location.href='page_check.php?Box =' +
document.formName.textboxName.value "Go check </a>

Any suggest ?
Regards
Since checking of a database is done on the server, it seems to me that
what you want is AJAX. Have an "onclick=foo()". In foo you would make
the AJAX call and return a message to the browser depending upon whether
there is no match or is a match. If this is for checking before
submitting the page, then get rid of the check button, keep the action
as the where you want the page submitted to, put a "return foo()" in the
form definition, and return either false or true from foo.

What do you mean by it doesn't work? Does the php file not see the
value? Does the php file see the value, but you don't get values back
to the current page? What happens?
Jul 8 '08 #2
On Jul 7, 9:03 pm, pt36 <key.albe...@gmail.comwrote:
Hi

I have a page with a form and a textbox.
before to submit the form I want to chek if the inserted value in the
textbox is already present in a database.
So I need to pass the textbox value by a javascript link to another
page to check.
my code is
<a href="javascript:location.href='page_check.php' "Go check </a>
and this work and open page_check.php

but when I want to append the textbox value, the code not work. I know
I make mistake

<a href="javascript:location.href='page_check.php?Box =' +
document.formName.textboxName.value "Go check </a>

Any suggest ?
Regards
this:

<html>
<head>
<script>
function changeURL(){
var lnk = document.getElementById('somelink');
lnk.href = lnk.href + "?" + document.getElementById('txtbx').value;
}
</script>
</head>
<body>
<input type="text" value="" id="txtbx" />
<a href="some_file.html" id="somelink"><input type="button"
value="Check it" onmousedown="changeURL();" /></a>
</body>
</html>

Or, I think this one is better:

<html>
<head>
<script>
function changeURL(){
window.location = "some_file.php" + "?" +
document.getElementById('txtbx').value;
}
</script>
</head>
<body>
<input type="text" value="" id="txtbx" />
<input type="button" value="Check it" onmousedown="changeURL();" />
</body>
</html>
Jul 9 '08 #3
On Jul 7, 9:03 pm, pt36 <key.albe...@gmail.comwrote:
Hi

I have a page with a form and a textbox.
before to submit the form I want to chek if the inserted value in the
textbox is already present in a database.
So I need to pass the textbox value by a javascript link to another
page to check.
my code is
<a href="javascript:location.href='page_check.php' "Go check </a>
and this work and open page_check.php

but when I want to append the textbox value, the code not work. I know
I make mistake

<a href="javascript:location.href='page_check.php?Box =' +
document.formName.textboxName.value "Go check </a>

Any suggest ?
Regards
you can try this:

<html>
<head>
<script>
function changeURL(){
var lnk = document.getElementById('somelink');
lnk.href = lnk.href + "?" + document.getElementById('txtbx').value
}
</script>
</head>
<body>
<input type="text" value="" id="txtbx" />
<a href="some_file.php" id="somelink"><input type="button"
value="Check it" onmousedown="changeURL();" /></a>
</body>
</html>

or, I think this is better:

<html>
<head>
<script>
function changeURL(){
window.location = "some_file.php" + "?" +
document.getElementById('txtbx').value;
}
</script>
</head>
<body>
<input type="text" value="" id="txtbx" />
<input type="button" value="Check it" onmousedown="changeURL();" />
</body>
</html>
Jul 9 '08 #4
Doug Gunnoe wrote:
Or, I think this one is better:
Better in which regard?
<html>
<head>
<script>
function changeURL(){
window.location = "some_file.php" + "?" +
document.getElementById('txtbx').value;
}
</script>
</head>
<body>
<input type="text" value="" id="txtbx" />
<input type="button" value="Check it" onmousedown="changeURL();" />
</body>
</html>
This is but an invalid, inefficient, error-prone tag soup.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jul 9 '08 #5
On 8 Lug, 12:49, sheldonlg <sheldonlgwrote:
pt36 wrote:
Hi
I have a page with a form and a textbox.
before to submit the form I want to chek if the inserted value in the
textbox is already present in a database.
So I need to pass the textbox value by a javascript link to another
page to check.
my code is
<a href="javascript:location.href='page_check.php' "Go check </a>
and this work and open page_check.php
but when I want to append the textbox value, the code not work. I know
I make mistake
<a href="javascript:location.href='page_check.php?Box =' +
document.formName.textboxName.value "Go check </a>
Any suggest ?
Regards

Since checking of a database is done on the server, it seems to me that
what you want is AJAX. *Have an "onclick=foo()". *In foo you would make
the AJAX call and return a message to the browser depending upon whether
there is no match or is a match. *If this is for checking before
submitting the page, then get rid of the check button, keep the action
as the where you want the page submitted to, put a "return foo()" in the
form definition, and return either false or true from foo.

What do you mean by it doesn't work? *Does the php file not see the
value? *Does the php file see the value, but you don't get values back
to the current page? *What happens?- Nascondi testo citato

- Mostra testo citato
ok Well
i have a page that submit a form. In the page, near to the textbox
when a user insert his nik, I want that the user be alerted that the
nik inserted in the textbox is already used, so have to choose
another. I will that this happen before to submit the form.
In php after submitting the page I am able to check this, and also I
not need help for the php code for this.
I am able to make this procedure and see the alert in a new windows
popup.
I will that the alert appear in the page, near the textbox, (in a DIV)
If an Ajax procedure helps me i say thanks, please send suggestions.

When I say "not work" I mean that the link was wrote not corrected and
not work.
if you write my code you see what happen
In the first example the link open the page page_check.php
In the second example the link not open the page_page.php and the link
path is incorrect.

eg. When a user try to register to yahoo, when you write your
username, sometime you receive a warning that your username is not
available. I want to do the same.
Regards
Jul 9 '08 #6
pt36 wrote:
i have a page that submit a form. In the page, near to the textbox
when a user insert his nik, I want that the user be alerted that the
nik inserted in the textbox is already used, so have to choose
another. I will that this happen before to submit the form.
In php after submitting the page I am able to check this, and also I
not need help for the php code for this.
I am able to make this procedure and see the alert in a new windows
popup.
I will that the alert appear in the page, near the textbox, (in a DIV)
Apparently you don't mean an alert message window. Note that `alert' has
a somewhat fixed meaning when dicussion client-side scripting, denoting
window.alert(). That may have caused confusion.
If an Ajax procedure helps me i say thanks, please send suggestions.
<http://developer.mozilla.org/en/docs/AJAXis a good starting point. You
should also search the Google archives of this newsgroup, there are plenty
of XHR examples in it (many of them posted by me).

As for the form, here is a template for you to experiment with:

<form action="..." onsubmit="return checkUser(this)">
<script type="text/javascript">
function checkUser(f)
{
// use wrapper object with feature test here instead
var x = new XMLHttpRequest();

// "synchronous" request to request plain text (SJAT ;-))
x.open("GET", "/check_user?user="
+ encodeURIComponent(f.elements["username"].value), false);
x.send(null);
if (x.status == 200 && x.responseText == "1")
{
// user exists already
return false;
}
else
{
return true;
}
}
</script>

<input name="username">
<input type="submit">
</form>
When I say "not work" I mean that the link was wrote not corrected and
not work.
Your approach appears to be wrong in the first place. See also
<http://jibbering.com/faq/#FAQ4_24>.
eg. When a user try to register to yahoo, when you write your
username, sometime you receive a warning that your username is not
available. I want to do the same.
Are you sure this warning is displayed before the register form is
submitted? If yes, you can simply look at Yahoo's source code to see how it
was done client-side, and with Firebug and LiveHTTPHeaders you can see what
is requested from the server and how the HTTP response looks like.
HTH

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jul 9 '08 #7
On 9 Lug, 10:01, pt36 <key.albe...@gmail.comwrote:
On 8 Lug, 12:49, sheldonlg <sheldonlgwrote:


pt36 wrote:
Hi
I have a page with a form and a textbox.
before to submit the form I want to chek if the inserted value in the
textbox is already present in a database.
So I need to pass the textbox value by a javascript link to another
page to check.
my code is
<a href="javascript:location.href='page_check.php' "Go check </a>
and this work and open page_check.php
but when I want to append the textbox value, the code not work. I know
I make mistake
<a href="javascript:location.href='page_check.php?Box =' +
document.formName.textboxName.value "Go check </a>
Any suggest ?
Regards
Since checking of a database is done on the server, it seems to me that
what you want is AJAX. *Have an "onclick=foo()". *In foo you would make
the AJAX call and return a message to the browser depending upon whether
there is no match or is a match. *If this is for checking before
submitting the page, then get rid of the check button, keep the action
as the where you want the page submitted to, put a "return foo()" in the
form definition, and return either false or true from foo.
What do you mean by it doesn't work? *Does the php file not see the
value? *Does the php file see the value, but you don't get values back
to the current page? *What happens?- Nascondi testo citato
- Mostra testo citato

ok Well
i have a page that submit a form. In the page, near to the textbox
when a user insert his nik, I want that the user be alerted that the
nik inserted in the textbox is already used, so have to choose
another. I will that this happen before to submit the form.
In php after submitting the page I am able to check this, and also I
not need help for the php code for this.
I am able to make this procedure and see the alert in a new windows
popup.
I will that the alert appear in the page, near the textbox, (in a DIV)
If an Ajax procedure helps me i say thanks, please send suggestions.

When I say "not work" I mean that the link was wrote not corrected and
not work.
if you write my code you see what happen
In the first example the link open the page page_check.php
In the second example the link not open the page_page.php and the link
path is incorrect.

eg. When a user try to register to yahoo, when you write your
username, sometime you receive a warning that your username is not
available. I want to do the same.
Regards- Nascondi testo citato

- Mostra testo citato
I Found this good tutorial and I solved
http://www.tutorialtoday.com/read_tutorial/115/
Thanks to all
Jul 9 '08 #8
SAM
pt36 a écrit :
I will that the alert appear in the page, near the textbox, (in a DIV)
If an Ajax procedure helps me i say thanks, please send suggestions.
Put the file with your form in a tag "object"
The answer will be send back in the same tag (without needing Ajax)
That works almost like an iframe

Then ... what to do with the answer is another question ;-)

--
sm
Jul 9 '08 #9
On Jul 8, 8:49 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
This is but an invalid, inefficient, error-prone tag soup.

PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Says you.

Anyway, sorry for the double post. I had some issues last night.

As to PointedEars comments, the answer I gave answered the question
she asked. Which I know is a rather difficult concept for you and a
few others to grasp. Not every question requires a lecture on
standards and specifications and best practice for crying out loud.

Furthermore, if I were trying to solve the problem she had, I would
have never used javascript. There is really no good reason to use it
for this problem, from what I can tell from her question.

But that's really not for me to say. She asked how to do something
using JavaScript and I gave her two workable solutions.

And don't respond to this with anything other than: "Yes Doug, you are
right and I, Thomas 'Pointed Ears' Lahn am wrong and humbly bey your
forgiveness".

And don't adjust the score either. So help me if you adjust the
score...

Jul 10 '08 #10
Doug Gunnoe wrote:
On Jul 8, 8:49 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>This is but an invalid, inefficient, error-prone tag soup.
[...] -- Bjoern Hoehrmann

Says you.
And I also say to you: Learn to quote. Finally.
[...]
As to PointedEars comments, the answer I gave answered the question
she asked. Which I know is a rather difficult concept for you and a
few others to grasp.
We strive to provide the best possible answers here, not the quickest ones.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jul 13 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Krechting | last post by:
Hi All, I tried to read the value of a textbox in another form. I have a page which contains one record. The textbox "txtWID" contains the autonumber of the record. I want to read this value in...
2
by: brian | last post by:
user input accepted via a input in the form. this value needs to be appended to the current url (explained below) ie say present url is www.xyz.com and the user is asked to enter his string and...
16
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not...
4
by: wrytat | last post by:
I have a form with a textbox for the user to enter a quantity and another textbox for the delivery date. I disabled this delivery date textbox such that the user has to press a calendar link next...
1
by: VB Programmer | last post by:
With HTML, how do I get the value of a textbox in an ItemTemplate column within a datagrid? Simple shopping cart. For each row: 1 column is a textbox where they can enter the quantity. 1...
3
by: forbin27 | last post by:
Need help - I'm new to javascript. I need to create a URL based on a textbox. Idea is user enters a number into a text box then clicks button which retrieves a link based on the number...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
5
by: shotokan99 | last post by:
for instance i do have this element but i dont have a <form>: <input type="Text" name="myname" id="myname" size="30"...> then i have this link: echo'<a...
5
by: maheswaran | last post by:
Hi all, My home page have login button to login the users. Am trying to use lightbox method in login screen. Using this when user click the loing button, login form will appear with lightbox effect...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.