Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

passing the different form variables

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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

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…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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

636 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