RE: question about displaying select and radio button

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi
 
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.      
echo "<input type =\"radio\" name=\"gender\" value=\"Male\" ";
if($gender=='Male') echo "checked";
echo ">Male";
echo "<input type =\"radio\" name=\"gender\" value=\"Female\" ";
if($gender=='Female') echo "checked";
echo ">Female";
 
 
option 1:
<input type="text" id="username" name="username"> <a
href="checkusername.php?username="+document.getElementById("username").value
>check availability</a>
 
Option 2:
<form name="frm1" id="frm1" ...>
<input type="text" id="username" name="username"> <a
href="javascript:document.frm1.submit();".>check availability</a>
</form>
 
 
Thanks,
Muthukumar Selvarasu,
Project Manager (Web Development),
Webmasters Ltd.
From: php-objects@xxxxxxxxxxxxxxx [mailto:php-objects@xxxxxxxxxxxxxxx] On
Behalf Of Sudhakar
Sent: Wednesday, January 02, 2008 2:00 AM
To: php-objects@xxxxxxxxxxxxxxx
Subject:  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.checked;
var f = document.confirmregistrationform.gender.Female.checked;
</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
 


[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux