Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

passing textfiled data by selecting checkbox

Featured Replies

Hi there,

 

i have tow text filed along with two text box. please see attached pic.post-9479-0-02651100-1404737232_thumb.jpg

 

 

check box1 text filed 1

check box2 text filed2

 

 

 

the is two page. the index.php page contains the forms with checkbox. and there is another page called new new.php. sucessfully after fuling the form /s the page submit the data to page new.php.

 

but what i want is...

 

if the check box 1 is selected then text filed 1 data will submit. not the text field 2 data.

 

or if check box 2 selected the text field 2 data will submit. not the textfiled1 data.

 

How can i do this??

 

any help in this issue?

 

advance thankspost-9479-0-02651100-1404737232_thumb.jpg

 

here is my code

 

index.php

 

<html>
<body>
<form action="new.php" method="post">
<table width="582" height="149">
  <tr>
    <td width="68"><label>
      <input type="checkbox" name="abeer1" id="abeer1">
    </label></td>
    <td width="502"><label>
      <input type="text" name="name1" id="abeerf1">
    </label></td>
  </tr>
  <tr>
    <td><label>
      <input type="checkbox" name="abeer2" id="abeer2">
    </label></td>
    <td><label>
      <input type="text" name="name2" id="abeerf2">
    </label></td>
  </tr>
</table>
<input type="submit">
</form>



</body>
</html>

new.php

 

<html>
 <body>

 Hello <?php echo $_POST["name1"]; ?> <p>
 Hello <?php echo $_POST["name2"]; ?>
</body>
 </html> 

Edited by abeer

Change the checkbox to a radio like so

<html>

<body>
    <form action="new.php" method="post">
        <table width="582" height="149">
            <tr>
                <td width="68">
                    <label>
                        <input type="radio" name="abeer" id="abeer" value="1">
                    </label>
                </td>
                <td width="502">
                    <label>
                        <input type="text" name="name1" id="abeerf1">
                    </label>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        <input type="radio" name="abeer" id="abeer" value="2">
                    </label>
                </td>
                <td>
                    <label>
                        <input type="text" name="name2" id="abeerf2">
                    </label>
                </td>
            </tr>
        </table>
        <input type="submit">
    </form>
</body>

</html>
Then in your php code use something like this

 

$name = ($_POST['abeer'] == 1?$_POST['name1']:$_POST['name2']);

 

If you want me to explain anything just ask :)

Edited by D4Y0

  • Author

many thanks for your reply.

 

but what i need...

 

suppose we have 10 text filed or more then 10 with check box or radio button. every textfiled come along with chekbox or radio button. if we checked the chekbox or radion button for any of the text filed then data of the text of the certain textfiled will submit only. not other text fileld data will submit.

  • Author

thanksss brooooooooooo am checking the code

 

You can use javascript to do that

 

something like this http://jsfiddle.net/pG66K/1/

 

Or you could do this via PHP use the same sort of HTML as i posted above with radio buttons

$name = $_POST['name'.$_POST['abeer']];

 

I agree :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.