Solved

passing the different form variables

Posted on 2000-04-11
5
228 Views
Last Modified: 2006-11-17
dear experts,

I have to design a form having drop down list of cities and various links to different categories.

Now I want if someone selects one city and clicks on the link of category another script should be invojed pasing the values of city and link on whichit was clicked.

I am briefly giving the two codes below.

-----------
<html><head><title>
Trying It! </title></head>
<body>
<form>
<select name=city>
<option selected>Ludhiana
<option>Delhi
<option>Calcutta
</select><p>
<a href="result.php3?city=$city&mcat=rest>Restaurant</a><p>
<a href="result.php3?city=$city&mcat=cloth>Cloth</a><p>
</form>
</body></html>


-----------------
#result.php3

<html><head><title>
Trying It! </title></head>
<body>
<?
echo "$city";
print "<p>";
echo "$mcat";
?>
</body></html>
0
Comment
Question by:tripat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
us111 earned 50 total points
ID: 2703635
<html>
<head>
Sure, it doesn't work, when you have an href your param is sent by the method GET, so the form is not sent.
I've added some javascript on your link in order to submit the form and to get the variables.

<title> Trying It! </title>
</head>
<body>
<form name="myform" action="result.php3" method="post">
  <select name="city">
    <option value="Ludhiana"  selected>Ludhiana</option>
    <option value="Delhi">Delhi</option>
    <option>Calcutta</option>
  </select>
  <input type="hidden" name="mcat">
  <p><a href="javascript:document.myform.mcat.value='rest';document.myform.submit();">Restaurant</a>
  <br><a href="javascript:document.myform.mcat.value='cloth';document.myform.submit();">Cloth</a>
  <p>
</form>
</body>
</html>


but as for me, the better solution will be

<title> Trying It! </title>
</head>
<body>
<form name="myform" action="result.php3" method="post">
  <select name="city">
    <option value="Ludhiana"  selected>Ludhiana</option>
    <option value="Delhi">Delhi</option>
    <option>Calcutta</option>
  </select>
 
  <input type="radio" name="mcat" value="rest"> Restaurant
  <br>
  <input type="radio" name="mcat" value="cloth"> Cloth

</form>
</body>
</html>
0
 
LVL 1

Expert Comment

by:mafweb
ID: 2703642
this will not work :-)

try the following:

<select> as above,

then

<input type=submit name=mcat value=Restaurant>
<input type=submit name=mcat value=Cloth>
0
 
LVL 8

Expert Comment

by:us111
ID: 2703733
hmm the first version works :))
I've tried it :)) I never post a comment without testing :)))

except my second version, I've forgotten
<input type=submit name="Send" value="Send">  in the form
0
 
LVL 1

Expert Comment

by:mafweb
ID: 2703775
sorry us111,

this referred to the initial posting :)
0
 
LVL 1

Author Comment

by:tripat
ID: 2714796
thanks to both, but according to my need javascript has worked fine.

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question