0

I have Checkboxes, the last checkbox is OTHER if the user clicks it, a textbox will appear. I want to get the value of the textbox and pass it on my checkbox, I do not know how to do it. This is my code, I used loop to get the checked checkbox, and check if textbox is empty. I hope you can understand this. Thank You!

$n = count($_SESSION['sch']);
    $schp="";
for($i=0;$i<$n; $i++)
{
    $schp .= $_SESSION['sch'][$i]. "; ";
}

    echo $schp;

if (empty($_POST['txtOSch'])){
    echo 'a';
}
else{
    $_SESSION['txtOSch'] = $_POST['txtOSch'];
    echo $_SESSION['txtOSch'];
}
2
Contributors
5
Replies
22
Views
3 Years
Discussion Span
Last Post by minitauros
0

I'm sorry but I find it kind of hard to understand your question :p. Is what you're asking: 'How do I pass the value of a textarea to a checkbox WHILE staying on the same page?' If yes, I'd say you'd have to use Javascript for that. If not, could you maybe rephrase your question?

0

Im sorry, Im getting all the values from another page, so I'm using session. Sorry for that.

0

So there's a textarea on page A, and a checkbox on page B, and a value from page A needs to be passed on to page B and given to a checkbox?

0

There are checkboxes(5) and textbox(1) in Page A, if the last check box is checked a textbox will appear, the value on that textbox will be passed on the checkbox (or any means to get the value of the textbox).

After that I want the value to be passed on Page B. Thank You!

0

Well, let's say you have this setup:

<input type="checkbox" name="a_checkbox0" value="a_value0">
<input type="checkbox" name="a_checkbox1" value="a_value1">
<input type="checkbox" name="a_checkbox2" value="a_value2">
<input type="checkbox" name="a_checkbox3" value="a_value3">
<input type="checkbox" name="a_checkbox4" value="a_value4">
<textarea name="a_textarea"></textarea>

Then on your PHP page, you could easily access the value of the textarea (once the form is submitted), and use that value instead of the value of your checkbox? Like:

<?php
$last_checkbox_value = $_POST['a_checkbox4'];
$textbox_value = $_POST['a_textarea'];

// Use $textbox_value instead of $last_checkbox_value if you want that value.
// ..

Or do you want the checkbox to obtain the value of the textarea BEFORE the form is submitted?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.