473,507 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tall order: text hyperlink that sets var value + submits form


Folks,

I am working on a contact db using PHP and MySQL. My results so far outputs
a slimed down version of records to the browser. I would like to implement
a method whereby the user can click on a text link which will then show the
full record. I don't want to have hyperlinks with values incorporated in
the link (thus, I don't want to have http://www.example.com?abc=1234) - I
prefer to use a POST method thus what I would like to do is have my output
listed inside a form. Each record would have unique hidden form value using
either a <INPUT TEXT> or <INPUT CHECKBOX>. Each record would have a
hyperlink so that when the hyperlink is pressed, its respective unique
record ID is noted, then the form submitted.

I know something like this is possible - I can work out the PHP/MySQL part
of it myself - But my javascript is still far too junior to accomplish
something like this.

Can someone help steer me in the right direction? If they know of a working
example I'm sure I could read and re-write the script to fit in with my
project...

Breaking my problem down a bit... I know I can have an onClick event in my
<A HREF> tag... But how can I have it set a value in a hidden box, and then
post the form?

All help, via the newsgroup would be much appreciated...

thanks,
randelld
Jul 20 '05 #1
7 4856
Randell D. wrote:
I am working on a contact db using PHP and MySQL. My results so far
outputs a slimed down version of records to the browser. I would like to
implement a method whereby the user can click on a text link which will
then show the full record. I don't want to have hyperlinks with values
incorporated in the link (thus, I don't want to have
http://www.example.com?abc=1234) - I prefer to use a POST method
Why? You aren't changing anything on the server, so this is what GET is
designed for. Aside from being easier to deal with, it will allow people to
bookmark specific entries.
thus what I would like to do is have my output
listed inside a form. Each record would have unique hidden form value
using either a <INPUT TEXT> or <INPUT CHECKBOX>.
Why not using type="hidden"? That's designed for hidden inputs?
Each record would have a hyperlink so that when the hyperlink is pressed,
its respective unique record ID is noted, then the form submitted.
Great. So you are depending on JavaScript. This is not a good idea. The most
important thing to learn about JavaScript, is when not to use it.

http://tom.me.uk/scripting/submit.asp
Breaking my problem down a bit... I know I can have an onClick event in my
<A HREF> tag... But how can I have it set a value in a hidden box, and
then post the form?


It sounds like you would be better off having multiple forms, then trying to
edit one form based on the user selection.

--
David Dorward http://dorward.me.uk/
Jul 20 '05 #2

"David Dorward" <do*****@yahoo.com> wrote in message
news:bn*******************@news.demon.co.uk...
Randell D. wrote:
I am working on a contact db using PHP and MySQL. My results so far
outputs a slimed down version of records to the browser. I would like to implement a method whereby the user can click on a text link which will
then show the full record. I don't want to have hyperlinks with values
incorporated in the link (thus, I don't want to have
http://www.example.com?abc=1234) - I prefer to use a POST method
Why? You aren't changing anything on the server, so this is what GET is
designed for. Aside from being easier to deal with, it will allow people

to bookmark specific entries.
thus what I would like to do is have my output
listed inside a form. Each record would have unique hidden form value
using either a <INPUT TEXT> or <INPUT CHECKBOX>.
Why not using type="hidden"? That's designed for hidden inputs?
Each record would have a hyperlink so that when the hyperlink is pressed, its respective unique record ID is noted, then the form submitted.


Great. So you are depending on JavaScript. This is not a good idea. The

most important thing to learn about JavaScript, is when not to use it.

http://tom.me.uk/scripting/submit.asp
Breaking my problem down a bit... I know I can have an onClick event in my <A HREF> tag... But how can I have it set a value in a hidden box, and
then post the form?
It sounds like you would be better off having multiple forms, then trying

to edit one form based on the user selection.

--
David Dorward http://dorward.me.uk/

First off... I did mean to refer to a HIDDEN tag - the words didn't come out
the way I anticipated - my fault - sorry for being unclear...

Anyway... Your proposed solution though: I had thought of something like
that (though I have to admit, the CSS idea was new to me and a nice touch) -
but the solution doesn't meet my problem entirely... I would prefer to have
a numeric value passed (the record ID) as opposed to the the value of the
submit button... Thus if I were to have something like a hidden field, a
hyperlink around the persons name, address and other contact details which,
when clicked, passed a record id (numeric value) to the hidden field, and
then submitted the form... that is more preferable.

I've read the link you supplied - It briefly details incorrect usages and
summarises it with "all are very poor usage of the A element". In my
ignorance, I would beg to differ (I'm not looking to get flamed but am open
to being educated through this newsgroup).

Why else do the A tag have the onClick feature? I know that the A tag is for
navigational purposes, but the onClick feature allows one extra
functionality...

Most modern day graphical browsers have javascript - It helps reduce the
load on the server and share some of the processing with the client. If
users are to disable javascript, then they disable functionality and are
unlikely to see something any more informative then the equivalent of junk
mail that would come through the door (ie fixed/static and less
interactive). Putting it bluntly, one doesn't get something for nothing in
this world - Even if its just free (as in beer) - folk always get something,
be it a laugh or a smile (ie happiness), information, goods or cash for the
bank...

Roughly speaking one could compare javascript to whistles and bells, music
and lights in a bricks and mortar business. If given the choice of two
stores selling the same goods on the same street, I'd be more likely to
enter the brighter, colourful and more welcoming one then the grey bricked
1950s paint job dimly lit uuncomfortably cold looking building...

While I do intend to design my pages to have a static (non javascript)
navigation on them, I aim to place less than 10% of my resources in this way
as if they (the client/viewers) are not interested in helping me help them
then they can spend extra time navigating elsewhere to find their info... I
know its crude - but I aim to create an application online (small time
application service provider) and I have 18months experience identifying my
market... During this time I analysed log files and discovered less than 2%
(of my likely market) had javascript disabled - some months went by where
less than one tenth of 1% were non-javascript browsers.

So... again... I do like your CSS solution - kudos for that and its
something I'm sure I will refer to later - but for now, I'd prefer to have a
clickable hyperlink that writes a numeric value in to a hidden field and
then submits the form...

Can you help me there?

Cheers
Randell D.
Jul 20 '05 #3

"Randell D." <yo**************************@yahoo.com> wrote in message
news:CC0ob.219266$9l5.170568@pd7tw2no...

Folks,

I am working on a contact db using PHP and MySQL. My results so far outputs a slimed down version of records to the browser. I would like to implement a method whereby the user can click on a text link which will then show the full record. I don't want to have hyperlinks with values incorporated in
the link (thus, I don't want to have http://www.example.com?abc=1234) - I
prefer to use a POST method thus what I would like to do is have my output
listed inside a form. Each record would have unique hidden form value using either a <INPUT TEXT> or <INPUT CHECKBOX>. Each record would have a
hyperlink so that when the hyperlink is pressed, its respective unique
record ID is noted, then the form submitted.

I know something like this is possible - I can work out the PHP/MySQL part
of it myself - But my javascript is still far too junior to accomplish
something like this.

Can someone help steer me in the right direction? If they know of a working example I'm sure I could read and re-write the script to fit in with my
project...

Breaking my problem down a bit... I know I can have an onClick event in my
<A HREF> tag... But how can I have it set a value in a hidden box, and then post the form?

All help, via the newsgroup would be much appreciated...

thanks,
randelld


I think I got what I was looking for... my lack of javascript experience had
made my previous attempts to fail because I had neglected to use 'value' (an
object? class? whatever its called) in my original script... but for anyone
that is interested in playing around themselves... this is my rough test
script that I plan on implementing with my PHP/MySQL scripts... Thank to all
who offered help via posts and emails (newsposts are always preferable).

<script language="JavaScript" type="text/JavaScript">
function one(myvalue)
{ document.form1.myname.value=myvalue;
return(TRUE);
}
</script>

<form name="form1" action="" method="post">Name:
<input name="myname" type="text" value="">
<a href="#" onClick="one(3); return">Click Here</a>
</form>
Jul 20 '05 #4
Randell D. wrote:
I've read the link you supplied - It briefly details incorrect usages and
summarises it with "all are very poor usage of the A element". In my
ignorance, I would beg to differ (I'm not looking to get flamed but am
open to being educated through this newsgroup).

Why else do the A tag have the onClick feature?
Because all rendered elements have an onclick event! And because you can do
USEFUL things with it that don't cause a page to depend on JavaScript.

For instance:

<h3 id="sheep">A subheading: Sheep</h3>

and somewhere else on the page:

.... however, <a href="#sheep"
onclick="document.getElementById('sheep').style.ba ckgroundColor='yellow';">sheep</a>
are a special case.

(A nicer version can be seen at <http://dorward.me.uk/software/frag/>)
I know that the A tag is for navigational purposes, but the onClick
feature allows one extra functionality...
Yes - EXTRA.
Most modern day graphical browsers have javascript
And a lot of people disabled it
- It helps reduce the load on the server and share some of the processing
with the client.
Using JavaScript to submit a form instead of a submit button does not reduce
the load on the server.
If
users are to disable javascript, then they disable functionality and are
unlikely to see something any more informative then the equivalent of junk
mail that would come through the door (ie fixed/static and less
interactive).
The great thing about the web is that its very easy to design a page that it
static and less interactive for users who don't have JavaScript, but has
flashy effects for those who do.
Roughly speaking one could compare javascript to whistles and bells, music
and lights in a bricks and mortar business. If given the choice of two
stores selling the same goods on the same street, I'd be more likely to
enter the brighter, colourful and more welcoming one then the grey bricked
1950s paint job dimly lit uncomfortably cold looking building...
See my previous paragraph in this post.
While I do intend to design my pages to have a static (non javascript)
navigation on them, I aim to place less than 10% of my resources in this
way as if they (the client/viewers) are not interested in helping me help
them then they can spend extra time navigating elsewhere to find their
info...


Not all users have don't run JavaScript do so by choice, and there is
nothing stopping you from writing static HTML... which looks nicer if the
user has CSS... and gets flashy if they have JavaScript. Good JavaScript is
a great deal about manipulating a page rather then adding to it.
--
David Dorward http://dorward.me.uk/
Jul 20 '05 #5
David Dorward wrote:
Randell D. wrote:
I've read the link you supplied - It briefly details incorrect usages and
summarises it with "all are very poor usage of the A element". In my
ignorance, I would beg to differ (I'm not looking to get flamed but am
open to being educated through this newsgroup).

Why else do the A tag have the onClick feature?


Because all rendered elements have an onclick event!


You have a strange idea of "rendered elements." According to the HTML 4.01
Specification, the `onclick' attribute is valid for "All elements but
APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME,
ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE."[1] I cannot find a definition
of "rendered elements" in the Specification, however I do consider APPLET,
BR, FONT, FRAME and IFRAME to be rendered elements as a rendering engine
(like Netscape Gecko) is required to display them.

But no matter that intrinsic event handlers are part of HTML 4.01, their
support depends on the DOM of the UA.[2] `img' elements in the NS4-DOM,
e.g., have no `onclick' event handler (at least none that is working), so
the `a' element and its `onclick' handler is required there if you want
to execute JavaScript code when clicking an image.
PointedEars
___________
[1] http://www.w3.org/TR/html4/index/attributes.html
[2] http://www.w3.org/TR/html4/interact/....html#h-18.2.3

Jul 20 '05 #6
On Thu, 06 Nov 2003 12:24:22 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> wrote:
David Dorward wrote: however I do consider APPLET,
BR, FONT, FRAME and IFRAME to be rendered elements as a rendering engine
(like Netscape Gecko) is required to display them.
APPLET, FRAME, IFRAME are containers for other content - they are not
rendered, the content is. BR is not rendered (it takes no space -
what would you click on?) FONT is the exception certainly.
so
the `a' element and its `onclick' handler is required there if you want
to execute JavaScript code when clicking an image.


In NN4, which is not an HTML 4.01 user agent.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #7
Jim Ley wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
David Dorward wrote:
however I do consider APPLET, BR, FONT, FRAME and IFRAME to be rendered
elements as a rendering engine (like Netscape Gecko) is required to
display them.


APPLET, FRAME, IFRAME are containers for other content - they are not
rendered,


IBTD, what do you think Gecko does when I specify

<iframe
src="foobar.html"
width="200" height="100"
style="width:50%; border:2px solid red" <a href="foobar.html">blurb</a>
</iframe>

?
the content is. BR is not rendered


Depends on what you call `(to) render'. It is an interpreted element
that results in different display, namely a hard line-break.
so the `a' element and its `onclick' handler is required there if you
want to execute JavaScript code when clicking an image.


In NN4, which is not an HTML 4.01 user agent.


Which (if true) is irrelevant here since it was only an example for the fact
that recommended event( handler)s need not to be part of the DOM of the UA.
OTOH, there are proprietary event( handler)s supported only by specific
UAs, like IE's `onmousewheel'.
PointedEars

Jul 20 '05 #8

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

Similar topics

20
12352
by: Dannyboyo | last post by:
I have what I hope is a simple request. I can't really code in javascript, but I am pretty good at cusomizing it with slight modifications. I code in ASP and HTML. I am trying to capture customer...
5
1861
by: cmc_dermo | last post by:
I have a form that has a select list. A user chooses a value and the page refreshes showing the selected value in the dropdown box. So I want to use Javascript to get the selected query from...
12
1977
by: Paul T. RONG | last post by:
Is it possible to divide a tall subform with 80 records to two subforms each with 40 records? Dear All, What I have: Tables: tblProduct, tblOrder, tblOrderDetail
19
3466
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred...
2
1863
by: Jan | last post by:
In a 2-page order form, not all applicants will complete it due to field validations. If I want to see data from incomplete orders, can this be done using some sort of session control so that each...
8
2564
by: Sohan Kamat | last post by:
Hi, I have a webform and I want to create a hyperlink to a text file, so that it opens on internet explorer in a new window. I have added the following <a href="file:///D:/Test/Test.txt" ...
5
1897
by: Alex | last post by:
Hello, I hope I can explain this properly. I'm writing an application with a tabbed-based navigation, and a form which gets filled out by users will be split into 5 subtabs. What I need is...
3
1530
by: groups2 | last post by:
I have a form with a dropdown (select) menu a text input field and some hidden values, along with an input botton that triggers an ajax function that submits the form. If the button is after the...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
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
7377
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...
1
7034
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
5623
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,...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
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...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.