473,666 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question about displaying select and radio button

54 New Member
hi

i have registration form where user selects from a drop down to select their area code apart from filling other details in the form. in the next page which is a confirmation page i would like to display the select option that a user choose in the first page i am able to display this using a textfield however i would like to display using the select drop down.

following is the code for both select and radio button that i have used.

1. Select tag

$pcontactnumber = addslashes($_PO ST["pcontactnumber "]);

<select name="pcontactn umber">
<option value="09"> <?php if $pcontactnumber == "09" echo "selected" ?>09</option>
<option value="07"> <?php if $pcontactnumber == "07" echo "selected" ?>07</option>
</select>

2. radio button
<script language="javas cript">

var m = document.confir mregistrationfo rm.gender.Male. checked;
var f = document.confir mregistrationfo rm.gender.Femal e.checked;
</script>

echo "<input type =\"radio\" name=\"gender\" value=\"Male\" if($gender=='Ma le') m // Male";
echo "<input type =\"radio\" name=\"gender\" value=\"Female\ " if($gender=='Fe male') f // Female";

2. radio button
echo "<input type =\"radio\" name=\"gender\" value=\"Male\" if($gender=='Ma le') {gender.checked }>Male";
echo "<input type =\"radio\" name=\"gender\" value=\"Female\ " if($gender=='Fe male') {gender.checked }>Female";


please correct the code and provide the correct syntax to display the information for select tag and radio button in the confirmation page using php


also i have another question, how can i pass a variable to a php file when a user clicks on a link without submitting a form
Ex:
Please choose your user name <input type="text" name="username" > <a href="checkuser name.php">check availability</a>

i have tried document.myform .submit(); onclick event for the <a> tag however it does not work

please advice.

thanks
Jan 1 '08 #1
1 2822
rycopiero`
3 New Member
is the select tag that you give us is in confirmation page?
if yes, you must get the variabel that passing from registration form, i think it can be like this..

in registration form :
<select name="pcontactn umber">
<option value="09"> 09</option>
<option value="07"> 07</option>
</select>

in confirmation page :
<select name="pcontactn umber">
<?
$pcontnumber = $_POST["pcontactnumber "];
?>
<option value="09" <? if ($pcontnumber == "09") echo "selected" ?> > 09 </option>
<option value="07" <? if ($pcontnumber == "07") echo "selected" ?> > 07 </option>
</select>

u can try like that.
for second quest. u can use this :
<a href="something _page.php?varia blename=variabl evalue">link</a>

exp :
<a href="check.php ?id=2">link</a>

be sure "=" and "?" sign cant have a space in left and right... check.php?id=2
Jan 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5242
by: JT | last post by:
I have an input form for which I've created a "matrix" for user input. Basically, the user chooses a radio button and then through javascript, a select box is displayed to define a value for that radio option, like so: Choice: (Radio1) type: (select box1) Choice: (Radio1) type: (select box2) Choice: (Radio1) type: (select box3) Choice: (Radio1) type: (select box4) Choice: (Radio1) type: (select box5)
5
3095
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the user clicks on the "Choose" button of the input field (to select a file on the local disk), then radio button B is automatically
2
3941
by: lltaylor | last post by:
Hello, I am trying to create a form which when initially displayed only has 2 radio buttons. Then based on which radio button you select the appropriate form appears below the radio buttons. What is the best of way of achieving this? Can I layer the form objects?
2
2815
by: Ron | last post by:
I want to add radio buttons to a datagrid. The datagrid is displaying 5-10 items, and I want the user to select the desired item via radiobutton. As it is, the user can select as many radiobuttons as they want, which is obviously not what I want. I want to limit the user to being able to select one radiobutton at a time. How can I add a radiobutton list to a datagrid? Does anyone have a suggestion/example? Thanks,
1
2972
by: Joe Attardi | last post by:
Hi all, On a form on one of my pages I have two <select> elements, and each one is paired up with a radio button. The idea is to choose an item from one list or the other and select the radio button of the list you want to use. I'm using JavaScript to automatically select the radio button corresponding to a list when you click on the list (using the onclick event handler). Is that the best event to change on, or should this
3
3056
by: TORQUE | last post by:
Hi How can I make a radio button create an action like enabling or disabling a delete button in a form? TIA TORQUE
2
1535
by: IchBin | last post by:
I am trying to clean up my code. I have run it through tidy and now have the code below. The problem is that anytime I select a radio button I get the following error: Forbidden You don't have permission to access /quotes/'.$_SERVER.'> <table style= on this server. -------------------------------------------------------------------------------- Apache/2.0.59 (Win32) mod_jk/1.2.15 SVN/1.4.0 PHP/5.2.0 DAV/2 Server at
11
2090
by: shror | last post by:
hi every body I need help please i have designed an image gallery of about 20 pictures and they are shown in thumb nail views and for viewing the largeer version of the images i have added a radio button and a push button, so that the user choose the picture using the radio button and click on the push button to open the larger version picture in another window, but my problem is that i know how to pass the selection to the second page...
11
2418
by: dba | last post by:
Have been displaying data from database using html for some time but just recently trying to display data back to "form". Can't find answer. <form method="post" action="<?php echo $PHP_SELF;?>"> First Name:<input type="text" size="12" maxlength="12" name="Fname"><br > Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br /> Gender:<br /> Male:<input type="radio" value="Male" name="gender"><br /> Female:<input...
0
8444
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
8869
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...
1
8551
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
8639
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...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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
4198
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...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.