473,386 Members | 1,706 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,386 software developers and data experts.

HREF within a FORM

I want to give the user two display choices with radio buttons at the
top of the page. Then I want to provide a series of HREF type links for
them to click on for the choice made. Is it possible to mix HREF links
with FORM radio buttons so that when the user clicks on the HREF link,
one of the radio button choices is included in the GET or POST data
sent to the next URL?

Jul 24 '05 #1
6 11764
In article <11*********************@l41g2000cwc.googlegroups. com>,
bf******@texarkanacollege.edu enlightened us with...
I want to give the user two display choices with radio buttons at the
top of the page. Then I want to provide a series of HREF type links for
them to click on for the choice made. Is it possible to mix HREF links
with FORM radio buttons so that when the user clicks on the HREF link,
one of the radio button choices is included in the GET or POST data
sent to the next URL?


Yes and no.
Javascript when the text is clicked instead of using an actual href, more
than likely.

Be more specific about what you're trying to accomplish and the architecture
of the application / pages.
There are always lots of ways to do things -- you want to chose the best way
for what you're doing.

--
--
~kaeli~
She was engaged to a boyfriend with a wooden leg but broke
it off.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 24 '05 #2
Here's what I want to do:
-------------------------------------------------------------
<form "myform">
Click here for choice 1<input type="radio" name="choice" >
Click here for choice 2<input type="radio" name="choice" >

....later in the HTML code...

<a href="nextcgi.cgi?choicemade=*&otherdata=xyz>Click here to see the
results of your choice for xyz</a>

<a href="nextcgi.cgi?choicemade=*,otherdata=abc>Click here to see the
results of your choice for abc</a>

....there could be a lot of these href links ...

-----------------------------------------------------------
See where the asterisk is after "choicemade=" in the href
link?...that's where I want to substitute something that indicates
which radio button was pressed. I may need a javascript function, but
I'm not sure exactly how to implement it.

Jul 24 '05 #3
In article <11*********************@f14g2000cwb.googlegroups. com>,
bf******@texarkanacollege.edu enlightened us with...
Here's what I want to do:
-------------------------------------------------------------
<form "myform">
Click here for choice 1<input type="radio" name="choice" >
Click here for choice 2<input type="radio" name="choice" >

...later in the HTML code...

<a href="nextcgi.cgi?choicemade=*&otherdata=xyz>Click here to see the
results of your choice for xyz</a>

<a href="nextcgi.cgi?choicemade=*,otherdata=abc>Click here to see the
results of your choice for abc</a>

...there could be a lot of these href links ...

-----------------------------------------------------------
See where the asterisk is after "choicemade=" in the href
link?...that's where I want to substitute something that indicates
which radio button was pressed. I may need a javascript function, but
I'm not sure exactly how to implement it.


Okay, is this carved into stone?

Because what I'm seeing here is that you want some clickable text that takes
a user to another page that is always the same page, but with different GET
params. How many more parameters are actually in the real code? If it is just
this one, than a simple solution would be to put that in a hidden form field
instead of the url and have the clickable text change the form field value
and submit the form as GET, putting the values in the URL.

This would create a javascript dependency. If your users may not have
javascript, you should at least have a fallback "noscript" page or something
to direct them to, i.e.
<a href="noscript.html" onClick="go(abc); return false;">Click here to see
the results of your choice for abc</a>

--
--
~kaeli~
Profanity: the single language in which all programmers are
expert.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 24 '05 #4
Here is exactly what I want to do:
-------------------------------------------------------------------
<head>
<title>Test HREF with RADIO buttons</title>

<SCRIPT LANGUAGE="JavaScript">
<!--
function WhichButton()
{
var choice1 = eval("document.myform.choice[0].checked")
var choice2 = eval("document.myform.choice[1].checked")

if (choice1 == true) return 1
else return 2
}
//-->
</SCRIPT>

</head>

<form "myform">
Click here for choice 1<input type="radio" name="choice" value=1><br>
Click here for choice 2<input type="radio" name="choice" value=2><br>

<hr>
<a href="next.cgi?code=javascript:WhichButton()&other =abc">ABC</a><br>
<a href="next.cgi?code=javascript:WhichButton()&other =xyz">XYZ</a><br>

<! ...there will be many more href tags here...>

<hr>

</form>

-------------------------------------------------------------------
There will be only two radio buttons at the top of the displayed page.
There could be many href tags, each with different "other" values.

In the href tag, see where I try to invoke the javascript function
WhichButton()? Well, that is where I want to have it substitute the
value 1 or 2 returned from the function so that it sends
"next.cgi?code=1&other=abc" if the user clicks on the first link after
first choosing radio button 1,
or
"next.cgi?code=2&other=abc" if the user clicks on the first link after
first choosing radio button 2.

Jul 24 '05 #5
In article <11*********************@o13g2000cwo.googlegroups. com>,
bf******@texarkanacollege.edu enlightened us with...
Here is exactly what I want to do:
-------------------------------------------------------------------
<head>
<title>Test HREF with RADIO buttons</title>

<SCRIPT LANGUAGE="JavaScript">
<script type="text/javascript">
Language attribute is deprecated.
<!--
Don't need to comment it out any more. That went out of need with Netscape 3
or some such.
Just extra bytes in a file now.
function WhichButton()
{
var choice1 = eval("document.myform.choice[0].checked")
Eeek!
Eval is Evil. ;)
choice1 = document.myform.choice[0].checked;
should be just fine. The checked property is true or false anyway. No need
for eval. Actually, there is very, very rarely a need for the resource
glutton that is called eval.

Actually, see script below. You don't need it at all.
<a href="next.cgi?code=javascript:WhichButton()&other =abc">ABC</a><br>


Unfortunately, you can't do this.
As long as you're using javascript, do it all the way. ;)

I assume from your post that there is always only one 'other' value and it's
the only additional parameter.
Also note that radio buttons mean you always expect one value. That means one
should be checked by default. So I put that here.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
</head>

<body>
<script type="text/javascript">
function go(otherval)
{
document.myform.other.value=otherval;
document.myform.submit();
}
</script>

</head>

<form name="myform" action="next.cgi" method="get">
Choice 1<input type="radio" name="choice" value=1 checked><br>
Choice 2<input type="radio" name="choice" value=2><br>
<input type="hidden" name="other" value="">
</form>

<hr>
<a href="#" onClick="go('abc'); return false;">ABC</a><br>
<a href="#" onClick="go('xyz'); return false;">XYZ</a><br>
<hr>

</body>
</html>
--
--
~kaeli~
Reading while sunbathing makes you well red.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 24 '05 #6
Thanks for your help--I figured it out.

Jul 24 '05 #7

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

Similar topics

4
by: Marcello | last post by:
Hello I have a page of 2 frame: menu (menu.php) corpo (corpo.php) In menu.php i have: <script> function selAut(){ aut=autore.selectedIndex; aut=autore.options.value;
4
by: Johnny | last post by:
I have a page with a button that has the following link: <a href="/somelink?org.apache.struts.taglib.html.TOKEN=ef9f9f5973be37ffe39c60227f402770#" onclick="javascript:go( event, 'myForm');return...
14
by: Brandon Hoppe | last post by:
I'm trying to change the src of an ilayer in the parent document from a link inside the ilayer. I'm not able to get it to work. All that happens is Netscape 4 crashes. This is for Netscape 4 only....
16
by: michael | last post by:
Is it possible to get all href URLs contained in a unordered list and place them in an array? Or in fact two different arrays, differently named one for each <ul> group? <ul> <li><a...
31
by: Yeah | last post by:
Is it absolutely necessary to include "http://" in an A HREF hyperlink? Would it be wise to remove this from one's Links page, just to save code?
1
by: wannieb | last post by:
I am hoping someone can help me in this little problem, I have a php page with dynamic menu boxes on it. SCRIPT ********* <!-- Below are arrays for the two dropdown menus and creates selected...
6
by: Dave Mennenoh | last post by:
I have a Flash based video player that uses a javaScript function on the page to modify variables within the Flash. This is so, external, jpg, thumbnails can change the video without reloading the...
14
by: Adnan Siddiqi | last post by:
Hi Suppose I have following URLs comming from an HTML document <a href="http://mydomain1.com">Domain1</a> <a...
1
by: Wolfman | last post by:
Hi gang! I've been searching for a solution to this problem extensively but nothing really hits the mark. I have a descriptive popup page that contains a PayPal order button. The normal PayPal...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.