fj1200 Posted October 16, 2008 Share Posted October 16, 2008 I have a similar question to Andy17 below. I'm fairly new to javascript. I have a number of SQL Server-driven php pages, but need a new set. I have 2 different sql queries dependent on a radio button selection to determine if a job being looked at is running or pre-completed - the data comes out of different tables and will populate a drop-down list. The form is the same whichever dataset is used. Radio buttons work fine, but I can't get the value passed to a query. Last part of the radio buttons: } if (chosen == "Running") { $JOBTYPE = 1 } else { $JOBTYPE = 0 } } The php-bit is: If ($JOBTYPE == "0") $JOBQRY = ($jobselect0); If ($JOBTYPE == "1") $JOBQRY = ($jobselect1); while($nt=mssql_fetch_array($JOBQRY)) { echo "<option value= $nt[JOB_NAME]"."$nt[JOB_DESCRIPTION]> $nt[JOB_DESCRIPTION]</option>"; } echo "</select>"; Does javascript get upset if I use a $ in a variable? If I don't php won't see it. Quote Link to comment https://forums.phpfreaks.com/topic/128695-change-db-query-depending-on-radio-button/ Share on other sites More sharing options...
RichardRotterdam Posted October 16, 2008 Share Posted October 16, 2008 just to be sure I need to ask you. you do know that php is serverside(runs on the server computer) and javascript is clientside(runs in browser) right? so this line in your code If ($JOBTYPE == "0") $JOBQRY = ($jobselect0); this will simply put $JOBTYPE in your javascript and not a usable value (off topic but the If should be with undercaps if) if you would write If (<?php echo $JOBTYPE ?>== "0") <?php echo $JOBQRY ?> = (<?php echo$jobselect0 ?>); that would be different Quote Link to comment https://forums.phpfreaks.com/topic/128695-change-db-query-depending-on-radio-button/#findComment-667026 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.