Forum Moderators: coopster
I Have a Drop menu that is populated from a mysql_querry
the array is built and all is good; but i need another value passed to a hidden field as to what option was selected.
Say i have the menu filled from mysql
<OPTION VALUE="Value1">Option1</OPTION>
<OPTION VALUE="Value2">Option2</OPTION>
<OPTION VALUE="Value3">Option3</OPTION>
and i select Option2, i need the Attributes that coresponds from Option2 in the database to be echoed to the hidden field within $PHP_SELF e.g. auto do it else on change or something so that the main form is ready to be submited with the new values.
Database Structure
¦-Field1 -¦-Field2 -¦-Field3 -¦-Attributes-¦
¦ Value1 ¦ Value2 ¦ Value3 ¦ The Attrib ¦
--------------------------------------------
The select tag
This is Populated from a MySQL DB
<SELECT Name="select">
<OPTION VALUE="Value1">Option1</OPTION>
<OPTION VALUE="Value2">Option2</OPTION>
<OPTION VALUE="Value3">Option3</OPTION>
</SELECT>
<INPUT TYPE="hidden" VALUE="<?PHH echo $the Attributes from what was selected?>">
How can i do this without using JavaScript and just PHP
i need it server side so in case the user has turned off JavaScript
HERE IS MY CURRENT SCRIPT:
<?PHP
$package_result = mysql_query("SELECT * FROM packages",$mysql_ID);
echo '<select name="package" TABINDEX="18"><OPTION>';
echo $myrow["package"];
echo "</OPTION>";
while ($row_item = mysql_fetch_assoc($package_result)){
$pname = $row_item["pname"];
echo "<OPTION value=\"$pname\">$pname</OPTION>";
}
echo '</SELECT>';
mysql_free_result ($package_result);
?>
<INPUT TYPE="hidden" VALUE="<?PHP echo $i need it here?>">
an alternative might be to have the javascript in place, but set the page to reload in the <noscript> or whatever you call it,
good luck
I guess i'll try and rephrase this.
I dont want JavaScript.
It was fun in the past but now that i am making application (Not big ones at that) for online use i realy realy dont want someone using this app with JavaScript turned off as it will not post proper information to the dabase.
This database is for RADIUS attributes passed to clients on a wide are Wireless ISP network.
So...
Say i have a drop list populated by a query to the database how can i sort the results?
there must be a way that says for what ever option you selected place its value in another variable NO? YES?
like say
if ($drop_list){
do this?
}
im not even sure if PHP can tell that a drop list has changed from what i know it only knows about SUBMIT buttons YES? NO?
i think that this is an interesting subject and should be looked into further.
Give me some input if you have time.
Thanks
the best way is to use javascript, then add something to say if the user has javascript disabled(there is an HTML tag for this) then reload evertime your thing changes
I think you answered my question.
I guess I was looking for a miracle basically searching for something that was never there.
I knew that PHP could not see anything that was there unless you submitted it but like the submit button when presses it can see that something has changed.
And i was thinking about a JavaScript not enabled kinda thing like (Sorry you don’t have JavaScript GO AWAY!) sorta thing but i did not know that there was a basic generic HTML tag to check it, if there is then maybe i will have to go that route cause like you say posting to many *.php script is very messy and i don't like it ether.
Right now my app (Not Form) is very large all within one file and I don’t want to mess with it.
So in conclusion:
What is this nifty tag that says you aint got JS?
if you don’t mind?
Thanks
<NOSCRIPT>
Bla Bla you aint got JS
</NOSCRIPT>
but hey i always try and go the extra mile.
How about this
Can PHP! check if JS in ON or OFF?
I think that checking it with PHP would be better
you can have a script that says if it aint on do this else if it is do this like...
if (JS=true){
My page and all of the rest of my scripts here
}else{
Get lost or turn on your JS or get a new browser
}
Oh! with my luck there is now way to do this
I guess i would have to make a stupid redirect if JS is true or just post a message, i realy hate having to make more files just to do one simple little thing.
Got any thought's?
Now if a guy come without JS he will see nothing but a message
else tada we be jaming
Great thanks a bunch.
Not to bug but can you help me out with a related problem.
My drop menu thing i decided to go another route.
make a list of links (unless you have a better idea)
from a query
and if a user clicks on a link the associated value will be entered into a hidden field.
link say
<A HREF="$PHP_SELF?blabla = this>$variable name here from the querry</A>
id this possible?