473,786 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing Data without Submit/Input

I want to get the user's choice of some menu items, and pass them to a
(PHP) page in the URL, rather than with "Submit" button. I tried
this, but it doesn't work:

<a href="pagetwo.p hp?says=meaning "><img src="smiley.gif "></a>

Pick one from drop-down menu:
<p>
<form>
<select name=meaning>
<option>Dopey
<option>Sneez ey
<option>Grump y
</select>
</form>
Jul 23 '05
16 9536
Ben Sharvy wrote:
I want to get the user's choice of some menu items, and pass them to
a (PHP) page in the URL, rather than with "Submit" button.
What is wrong with a submit button? If you want to pass the data using
via url, then use the GET method:

<form method="get" action="myscrip t.php">
I tried this, but it doesn't work:

<a href="pagetwo.p hp?says=meaning "><img src="smiley.gif "></a>

Pick one from drop-down menu:
<p>
<form>
<select name=meaning>
<option>Dopey
<option>Sneez ey
<option>Grump y
</select>
</form>


A form can only pass information via http. You can try js to accomplish
this, perhaps by modifying the href attribute of an <a> element, but why
go through all that bother when a basic form will work? That is, after
all, what the <form> element is meant for.

--
Brian (remove "invalid" to email me)
http://www.tsmchughs.com/
Jul 23 '05 #11

"Brian" <us*****@juliet remblay.com.inv alid> wrote in message
news:wg******** *************@b gtnsc04-news.ops.worldn et.att.net...
Harlan Messinger wrote:
<script type="text/javascript">
document.write ('<a onclick="docume nt.forms['myForm'].submit();"><im g
src="smiley.gif "></a>');
</script>

Use script to write this link, because if Javascript support is
unavailable or turned off then the link wouldn't work anyway. In that
case, it's replace below, inside a NOSCRIPT element, by the Submit
button that you're trying to avoid.
This is not the best authoring practices. What if js is enabled but the
code contains an error?


Don't use programming because it might be in error? Following that
philosophy, none of the software you use every day would have ever gotten
out the door. Obviously when anyone publishes software, it's after they're
satisfied that it's basically correct. Presumably, the man is going to
*test* his page before he releases it. It won't take him long to fully test
it--this isn't control software for satellite deployment or anything like
that.
Neither the js submit nor the <noscript> submit
button will be available.
If he accidentally types

<input type="sbumit" ...

the page will also be broken.

Better solution: create a fully functioning <form>, and use js to modify
the dom, removing the <input type=submit> and adding a js submit mechanism.
But then, the best solution for the op is to KISS, and use a normal form.


For the most part I agree.

Jul 23 '05 #12
Harlan Messinger wrote:
"Brian" wrote...
Harlan Messinger wrote:
<script type="text/javascript">
document.write ('<a
onclick="docume nt.forms['myForm'].submit();"><im g
src="smiley.gif "></a>');
</script>

Use script to write this link, because if Javascript support is
unavailable or turned off then the link wouldn't work anyway. In
that case, it's replace below, inside a NOSCRIPT element, by the
Submit button that you're trying to avoid.
This is not the best authoring practices. What if js is enabled but
the code contains an error?

Don't use programming because it might be in error?


No. Use programming in the safest way possible. In the context of the
www, that means start with a page that functions without js, then add js
to change that page if js is enabled. If you code the js correctly, then
the page will work when js is disabled; it will work when js is enabled
but the code goes awry; and it will work when js is enabled and works.
Presumably, the man is going to *test* his page before he releases
it.


This is the www, though. Noone can test in every release of every
browser. At least in principle, a browser can implement some js, but not
the document.write method. In that case, your suggestion would fail,
since the browser would not write the js link, but, since js is enabled,
it would ignore the contents of the <noscript> element.
Neither the js submit nor the <noscript> submit button will be
available.

If he accidentally types

<input type="sbumit" ...

the page will also be broken.


Fair enough, but a validator will point out that error. I suppose a js
debugger might point out js bugs, but I'm not sure it can pick up all
possible problems. You might write code that is free from errors, and
works in MSIE and Mozilla, but fails because of a js bug in Opera
7.1/WinXP. If you don't test in that particular version of Opera, you've
got a problem.

Take the op's request: instead of document.write, you create a js
routine that adds an onsubmit handler or a new link, then removes the
<input type="submit"> from the DOM. If some browser chokes on the code,
it will never get to the remove part of the script, and the page will
still work. Such a routine is not fool-proof, but is much safer than
assuming your code will always execute correctly.

--
Brian (remove "invalid" to email me)
http://www.tsmchughs.com/
Jul 23 '05 #13
Brian wrote:
Harlan Messinger wrote:
Brian wrote...

Don't use programming because it might be in error?

No. Use programming in the safest way possible.


That is, "No, I don't mean that you shouldn't use a programming language
because it might be in error. I only mean that you should use a
programming language in the safest way possible."

--
Brian (remove "invalid" to email me)
http://www.tsmchughs.com/
Jul 23 '05 #14
Brian <us*****@juliet remblay.com.inv alid> wrote:
Harlan Messinger wrote:
[snip]
Presumably, the man is going to *test* his page before he releases
it.


This is the www, though. Noone can test in every release of every
browser. At least in principle, a browser can implement some js, but not
the document.write method.


Isn't document.write an ancient, core Javascript method? I think it's
fair to assume that *if* a browser implements Javascript, it
implements its core functionality, at least to the extent that we
assume that browsers that implement HTML implement submit buttons.
In that case, your suggestion would fail,
since the browser would not write the js link, but, since js is enabled,
it would ignore the contents of the <noscript> element.
Neither the js submit nor the <noscript> submit button will be
available.

If he accidentally types

<input type="sbumit" ...

the page will also be broken.


Fair enough, but a validator will point out that error. I suppose a js
debugger might point out js bugs, but I'm not sure it can pick up all
possible problems. You might write code that is free from errors, and
works in MSIE and Mozilla, but fails because of a js bug in Opera
7.1/WinXP. If you don't test in that particular version of Opera, you've
got a problem.


A version of Opera could just as easily come out with a bug in the
submit button.

Take the op's request: instead of document.write, you create a js
routine that adds an onsubmit handler or a new link, then removes the
<input type="submit"> from the DOM. If some browser chokes on the code,
it will never get to the remove part of the script, and the page will
still work. Such a routine is not fool-proof, but is much safer than
assuming your code will always execute correctly.


I thought you were kidding when your first suggested that.
Interesting, on second thought. But--I believe document.write has
older and broader support than does DOM/DHTML code that can remove
elements.
--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 23 '05 #15
Harlan Messinger (hm************ *******@comcast .net) wrote:
: Brian <us*****@juliet remblay.com.inv alid> wrote:

: >Harlan Messinger wrote:

: [snip]

: >> Presumably, the man is going to *test* his page before he releases
: >> it.
: >
: >This is the www, though. Noone can test in every release of every
: >browser. At least in principle, a browser can implement some js, but not
: >the document.write method.

: Isn't document.write an ancient, core Javascript method? I think it's
: fair to assume that *if* a browser implements Javascript, it
: implements its core functionality, at least to the extent that we
: assume that browsers that implement HTML implement submit buttons.

I don't think he ever meant to suggest that any browser might have a bug
with document.write, I'm sure that choosing "document.write " was just the
easiest possible way to illustrate his point.

I more realistic bug might be something like "...an incompatibility with
the dom model when multiple frames are in use after selecting the back
button...". But if he's going to make up a bug (like I just did), why not
make up a bug that is simpler to explain?

And in my hyperthetical example, sure enough, his code would probably not
be able to remove the submit link due to the hyperthetical
"incompatibilit y with the dom model", and therefore the form would still
have at least one way to do the submit.

Jul 23 '05 #16
"Harlan Messinger" <hm************ *******@comcast .net> a écrit dans le
message de news:6p******** *************** *********@4ax.c om
The code I
provided wasn't meant to be inserted into the form, it was meant to
replace the link the OP was trying to use, in the same position.


Oh, OK. I missed that. Thanks

Jul 23 '05 #17

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

Similar topics

5
5943
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page contains: <?php $_SESSION = ""; $_SESSION = "";
1
7789
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains: ---------------------------------------------------------------------------- <?php ini_set("session.use_cookies", "off"); ini_set("session.use_trans_sid", "on"); session_start(); $_SESSION = ""; $_SESSION = ""; echo "<form method='POST' action='login.php'>
3
2081
by: redneck_kiwi | last post by:
Hi all: I have a really weird problem. I am developing a customer catalog system for my company and as such have delved into sessions for authentication and access levels. So far, I have managed to get a working system just about finished. I am building an interface for our customer service folks to use to manage registered customers and am seeing some weird behavior.
2
2548
by: Richard | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** HI, I am working on a project where I need to input data to a (local) HTML page using multiple form elements, such as text, radio, checkbox, and dropdown. When the form Submit button is clicked, I then need the input data either written to another location on the same page, or written to another page (a different frame would be fine)
10
2908
by: Noozer | last post by:
Below is some ASP, HTML and javascript. It is part of a page used to maintain a small database. This code did work at one time, but has since stopped. For some reason the data on my form is not being passed to the page specified in the Action property of the form. This is on a Windows 2000 Pro PC. I copied the code to another server (Windows XP Pro machine) and it DOES work as expected there. The first block is the data located near...
3
1778
by: Patrick Olurotimi Ige | last post by:
How can i send LOGON_USER or User.Identity.Name to the Database? I'm working on a survey which is intranet based with Windows Authentication. I can get the current user by calling LOGON_USER or User.Identity.Name ! But i want to pass(the current user) to a table in DB! I was thinking of ussing hidden textboxes like so :- Is it a good approach.. Any ideas appreciated!
7
2790
by: Khai | last post by:
First off, yes, I understand the crapload of tutorials out there, (well, rather, I understand there /are/ a crapload of tutorials out there), the problem is my comprehension. I'm trying to pass variables, and can do so just fine with a URL, and $_GET. What I would like to learn, and be very adept at using is the Form functions and how you pass through that. The problem in my comprehending this, is how does the original page know how...
4
2316
by: jej1216 | last post by:
I'm pretty new to PHP and MySQL. I have managed to create a form that inserts data to MySQL and to create a form to search the DB. Now here is my problem. I am unsuccessful coding a hidden variable in an update page. Here is what I have: search_ir.php (this page searches the DB and lists incident_id's found. User then enters the incident_id of the row to update): .... <FORM METHOD="POST" ACTION="edit_ir.php"> <h3>Enter the Incident...
3
6884
by: ToddFur | last post by:
I see several postings on this but I am still unable to figure out my problem. I can pass the values of my text field but not radio button (or even checkboxes). My PHP file <?php //declare our variables $day = $_GET; $date = $_GET; $groupname = $_GET;
0
9650
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8992
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6748
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.