Connecting Tech Pros Worldwide Help | Site Map

PHP PRINT statement with OnChange event

Michelle
Guest
 
Posts: n/a
#1: Jul 17 '05
I have tried every variation of the "onchange" statement below without
any actual reloading of the page. I am hoping that the PHP PRINT
statement is constructed wrong, otherwise it is javaScript error an
needs to be posted in the javaScript newsgroup.

The FireFox javaScript Console reports the following message:

Error: missing : in conditional expression
Source Code:
location.href=themes.php?scheme=(form.color_scheme s.options[form.color_schemes.selectedIndex].value)

My Code for the dropdown box is:
<form name='color_schemes' method='post' action='themes.php' >
Select a scheme:&nbsp;

<?php
print "<select name='scheme' size='1'
onchange='location.href=themes.php?scheme=(form.co lor_schemes.options[form.color_schemes.selectedIndex].value)'>\n";

//populate the dropdown selector box...
$counter = 1;

foreach ($schemes as $scheme)
{
if ($selected_theme == $counter)
print "<option value = '$counter' selected>$scheme</option>\n";
else
{
print "<option value = '$counter'>$scheme</option>\n";
}
$counter ++;
}

?>

I would appreciate any advice...its probably something that is very
trivial and a very glaring defect, but I am blind to it.

Thanks,

Miki
neur0maniak
Guest
 
Posts: n/a
#2: Jul 17 '05

re: PHP PRINT statement with OnChange event


> Error: missing : in conditional expression[color=blue]
> Source Code:
>[/color]
location.href=themes.php?scheme=(form.color_scheme s.options[form.color_schemes.selectedIndex].value)

Your error is on that line, and it's javascript. You've not put quotes
around the URL you want to reload
try this:
location.href='themes.php?scheme='+(form.color_sch emes.options[form.color_schemes.selectedIndex].value)

Michelle wrote:[color=blue]
> I have tried every variation of the "onchange" statement below without
> any actual reloading of the page. I am hoping that the PHP PRINT
> statement is constructed wrong, otherwise it is javaScript error an
> needs to be posted in the javaScript newsgroup.
>
> The FireFox javaScript Console reports the following message:
>
> Error: missing : in conditional expression
> Source Code:
> location.href=themes.php?scheme=(form.color_scheme s.options[form.color_schemes.selectedIndex].value)
>
>
> My Code for the dropdown box is:
> <form name='color_schemes' method='post' action='themes.php' >
> Select a scheme:&nbsp;
>
> <?php
> print "<select name='scheme' size='1'
> onchange='location.href=themes.php?scheme=(form.co lor_schemes.options[form.color_schemes.selectedIndex].value)'>\n";
>
>
> //populate the dropdown selector box...
> $counter = 1;
>
> foreach ($schemes as $scheme)
> {
> if ($selected_theme == $counter)
> print "<option value = '$counter' selected>$scheme</option>\n";
> else
> {
> print "<option value = '$counter'>$scheme</option>\n";
> }
> $counter ++;
> }
>
> ?>
>
> I would appreciate any advice...its probably something that is very
> trivial and a very glaring defect, but I am blind to it.
>
> Thanks,
>
> Miki[/color]
Closed Thread