Forum Moderators: open

Message Too Old, No Replies

textbox/dropdowns

         

leo gatmaytan

7:17 am on Sep 6, 2010 (gmt 0)

10+ Year Member



Hi,

how to get the value of text box / dropdowns from another page.?

I have a dropdown menu and textbox on a page and when they click submit.
I want to use the value they input in the textbox and dropdown on another page.

Thanks.

Porsche maniak

8:35 am on Sep 6, 2010 (gmt 0)

10+ Year Member



<form method=GET action=newpage.php>
<input name=opt id=opt value='' type=hidden>
<select ONCHANGE=document.getElementById('opt').value=this.options[this.selectedIndex].innerHTML;><option>First option</option><option>Second option</option></select>
<text area name=text></textarea>
<input value=Submit type=button>
</form>

Now you must have newpage.php
In this page you get the contents submited from the previous page with the following way :
$opt=$_GET[ 'opt' ]; // the selected dropdown value
$text=$_GET[ 'text' ]; // the typed text in text box

Use 'echo $opt;' and 'echo $text;' to show them.

rainborick

1:47 pm on Sep 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You don't absolutely have to use PHP or other server-side software. JavaScript can also work with a query string in a URL created with a <form> whose method is set to "GET". You can get the contents of a query string in location.search, as in:

params = new Array();
query = location.search;
params = query.split('&');

'params' then holds the name/value pairs from the query string.