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

question about displaying select and radio button

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($_POST["pcontactnumber"]);

<select name="pcontactnumber">
<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="javascript">

var m = document.confirmregistrationform.gender.Male.check ed;
var f = document.confirmregistrationform.gender.Female.che cked;
</script>

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

2. radio button
echo "<input type =\"radio\" name=\"gender\" value=\"Male\" if($gender=='Male') {gender.checked}>Male";
echo "<input type =\"radio\" name=\"gender\" value=\"Female\" if($gender=='Female') {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="checkusername.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 2783
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="pcontactnumber">
<option value="09"> 09</option>
<option value="07"> 07</option>
</select>

in confirmation page :
<select name="pcontactnumber">
<?
$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?variablename=variablevalu e">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
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...
5
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...
2
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. ...
2
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...
1
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...
3
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
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...
11
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...
11
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;?>">...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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.