By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,874 Members | 1,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,874 IT Pros & Developers. It's quick & easy.

PHP PRINT statement with OnChange event

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> Error: missing : in conditional expression
Source Code:
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: 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

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.