?
Solved

passing the different form variables

Posted on 2000-04-11
5
Medium Priority
?
237 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 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

765 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