PHP script help!!!!!

davide78

New Member
Messages
6
Reaction score
0
Points
0
Hi guys,

I need to do something that for a lot of you would be very easy, but for me, that I do not know anything of php language, it is very hard to accomplish.

What I want to do is to make a form field ( which I displayed below) add its details to the notes box after being submitted.

Basically, I want my customers to choose one of the rooms in this cascade menu:

<tr><td>Room*</td><td>

<select name="Room" class="bookingtext">
<option value="">Room...</option>
<option value="Praia de Buzios">Praia de Buzios</option>
<option value="Pirangi">Pirangi</option>
<option value="Praia do Amor">Praia do Amor</option>
<option value="Praia de Ponta Negra">Praia de Ponta Negra</option>
<option value="Baia dos Golfinhos">Baia dos Golfinos</option>
<option value="Praia de Genipabu`">Praia de Genipabu`</option>
<option value="Praia do Meio">Praia do Meio</option>
</select>
</td></tr>

and than, I would like the choice to be shown in the text box.

Can someone tell me, step by step, how to do it?

If necessary, I can post the whole
PHP:
program.
 

 Thank you very much for your support.

Davide78
 

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
So you want the value of the dropdown to also be in a corresponding textbox on the same page?
 

kidas

New Member
Messages
42
Reaction score
0
Points
0
hope this will help :




<?php
if(!empty($_GET['Room'])) echo "selected room <input type=text value=\"".addslashes($_GET['Room'])."\">";
else
echo "select a room :D";
?>
<form methode=get>
<tr><td>Room*</td><td>

<select name="Room" onchange=this.parentNode.submit(); class="bookingtext">
<option value="">Room...</option>
<option value="Praia de Buzios">Praia de Buzios</option>
<option value="Pirangi">Pirangi</option>
<option value="Praia do Amor">Praia do Amor</option>
<option value="Praia de Ponta Negra">Praia de Ponta Negra</option>
<option value="Baia dos Golfinhos">Baia dos Golfinos</option>
<option value="Praia de Genipabu`">Praia de Genipabu`</option>
<option value="Praia do Meio">Praia do Meio</option>
</select>
</td></tr>
</form>
 

davide78

New Member
Messages
6
Reaction score
0
Points
0
So you want the value of the dropdown to also be in a corresponding textbox on the same page? __________________
Thanks,
Brandon


Hi Gays,

Sorry, I was not very clear before....Yes, I want the value of the dropdown menu to show also in the textbox, which is in the same page.

Do you know how to do it?

Thank you

Daviden1
 
Last edited:

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
Do you want to store the option selected as well, or is it okay if it disappears after use?

BTW, you should all use the [ PHP] [ /PHP], [ HTML] [ /HTML], [ CODE] [ /CODE] (remove the spaces) tags when posting code on the forums.
 

swhybd3

New Member
Messages
1
Reaction score
0
Points
0
thnks i will flow it.....can u help me how can i creat a html site
 

davide78

New Member
Messages
6
Reaction score
0
Points
0
Do you want to store the option selected as well, or is it okay if it disappears after use?

Hi Guys,

Yes, I would like the option selected be stored in the textbox after the use...

Is it possible?

Thank you again.

Davide78
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Do you want to store the option selected as well, or is it okay if it disappears after use?
Yes, I would like the option selected be stored in the textbox after the use...
This doesn't answer xav's question.


JS would be a more efficient choice, as it would reduce a round-trip. You'd still want the PHP handler, for those browsers that have JS disabled or don't support JS.

HTML:
<form ...>
   <select name="Room" onchange="roomChange(this);">
      ...
   </select>
   <input name="RoomName" value="<?php isset($_REQUEST['RoomName']) && echo $_REQUEST['RoomName']; ?>"/>
</form>
<script type="text/javascript">
    function roomChange(roomField) {
        roomField.form.RoomName.value = roomField.value; 
    }
</script>
 

kidas

New Member
Messages
42
Reaction score
0
Points
0
hope this will help :



Code:
<?php
if(!empty($_GET['Room'])) echo "selected room <input type=text value=\"".addslashes($_GET['Room'])."\">";
else
echo "select a room :D";
?>
<form methode=get>
<tr><td>Room*</td><td>

<select name="Room" onchange=this.parentNode.submit(); class="bookingtext">
<option value="">Room...</option>
<option value="Praia de Buzios">Praia de Buzios</option>
<option value="Pirangi">Pirangi</option>
<option value="Praia do Amor">Praia do Amor</option>
<option value="Praia de Ponta Negra">Praia de Ponta Negra</option>
<option value="Baia dos Golfinhos">Baia dos Golfinos</option>
<option value="Praia de Genipabu`">Praia de Genipabu`</option>
<option value="Praia do Meio">Praia do Meio</option>
</select>
</td></tr>
</form>

hh anyone has see my code ?? it's not what u was looking for ??????? ppfffff
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
hh anyone has see my code ?? it's not what u was looking for ??????? ppfffff
Don't be so self-centered. Maybe you should have used the [ PHP] tags to make your code stand out, and also, as misson pointed out, there are better ways of achieving the same thing.

@davide78: do you want the value to be stored (kept on the server, so it always show up)
 

davide78

New Member
Messages
6
Reaction score
0
Points
0
Hi guys,

No, I do not want the value to be kept on the server... I just want to copy the value from the drop-down menu and paste in the text box.

ex.:* you select from drop-down menu the "Room N1"...

I want "RoomN1" copied and pasted into the Text box. ( text box which is already located just below the drop-down menu).


Thank you again

Davide78
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
Then you should consider misson's JavaScript example.
 
Top