Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PHP web control only works with Firefox

2 views
Skip to first unread message

Arch

unread,
Jul 2, 2010, 8:39:48 PM7/2/10
to
I'm having trouble making part of my web utility work on IE and chrome -
works great on FF.

I've constructed a "combo box"-like select control using data from
MySQL, like this:

echo "<SELECT name='selectStation' SIZE='1' style='width:150px;'>";

foreach ($myArray as $arrayItem) {
echo "<option value='$arrayItem'".
(($arrayItem == $equipmentRecord['Location']) ?
"selected='selected'" : "null").
" onClick='javascript:SubmitSerial();'>$arrayItem</option>";}

echo "</SELECT>";

This works perfectly in Firefox, but in IE and Chrome it doesn't respond
to my user. The box draws fine and my user can select another value from
the box, but the value specified by $equipmentRecord['Location'] is not
selected and the 'onclick' event won't fire my javascript function.

Any help is appreciated. Happy to supply more info if anyone wants it.

J.O. Aho

unread,
Jul 3, 2010, 2:25:49 AM7/3/10
to

Some browsers don't handle single quotes too well, I do suggest you use double
quotes to enclose data in the html-tags.

Don't use null in the html tag, just use an empty string instead.
Don't write together options, for example
<option value='something'selected='selected'
onClick='javascript:SubmitSerial();'>something</option>

don't work that well in all browsers.
If you use style, then take a step further and use css files and classes, then
you don't have to hack in your code to change the look.

function use_functions_which_returns_values($myArray) {
if(is_array($myArray) && count($myArray)) {
$string = '<select name="selectStation" size="1" class="selectStation">'."\n";
foreach($myArray as $arrayItem) {
$selected = ($arrayItem == $equipmentRecord['Location'])?'
selected="selected" ':'';
$string .= <<<EOS
<option value="{$arrayItem}" onclick="javascript:SubmitSerial();"
{$selected}>{$arrayItem}</option>
EOS;
}
$string .= '</select>'."\n";
} else
$string = 'No drop down';
return $string;
}

When it comes to your javascript bug, I suggest you use tools like firebug,
Chromium has it's own built in, MSIE you need to use visualstudio.

--

//Aho

Jerry Stuckle

unread,
Jul 3, 2010, 6:35:14 AM7/3/10
to

Try a javascript newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

Michael Fesser

unread,
Jul 3, 2010, 7:59:51 AM7/3/10
to
.oO(J.O. Aho)

>Arch wrote:
>> [...]


>>
>> This works perfectly in Firefox, but in IE and Chrome it doesn't respond
>> to my user. The box draws fine and my user can select another value from
>> the box, but the value specified by $equipmentRecord['Location'] is not
>> selected and the 'onclick' event won't fire my javascript function.
>
>Some browsers don't handle single quotes too well

Which?

>I do suggest you use double
>quotes to enclose data in the html-tags.

Both is allowed and works perfectly well.

Micha

Arch

unread,
Jul 3, 2010, 11:58:42 AM7/3/10
to
> if(is_array($myArray)&& count($myArray)) {

> $string = '<select name="selectStation" size="1" class="selectStation">'."\n";
> foreach($myArray as $arrayItem) {
> $selected = ($arrayItem == $equipmentRecord['Location'])?'
> selected="selected" ':'';
> $string .=<<<EOS
> <option value="{$arrayItem}" onclick="javascript:SubmitSerial();"
> {$selected}>{$arrayItem}</option>
> EOS;
> }
> $string .= '</select>'."\n";
> } else
> $string = 'No drop down';
> return $string;
> }
>
> When it comes to your javascript bug, I suggest you use tools like firebug,
> Chromium has it's own built in, MSIE you need to use visualstudio.
>
Let me work on the CSS angle,that may fix me up. And I installed Firebug
this morning, great utility. Thanks for the helpful advice, much
appreciated.

Grateful noob. :|


Arch

unread,
Jul 3, 2010, 1:47:28 PM7/3/10
to

Changed the 'onClick' event to 'onChange' and moved it to the SELECT
line instead of the individual Option lines. Works perfectly on all
browsers.

Jerry Stuckle

unread,
Jul 3, 2010, 2:36:47 PM7/3/10
to

Great. And next time, please ask your javascript questions in a
javascript newsgroup.

In case you haven't figured out - this newsgrout is alt.PHP, not
alt.JAVASCRIPT.

Jerry Stuckle

unread,
Jul 3, 2010, 2:38:11 PM7/3/10
to

Correct. That's a big reason why I recommend people ask javascript
questions (even simple ones) in a javascript newsgroup. Too many bad
answers in this newsgroup.

Arch

unread,
Jul 4, 2010, 3:25:31 PM7/4/10
to

Jer, here's your vocabulary builder word of the day: "Pissant"

Please note that I had the class to ignore you the first time.


Michael Fesser

unread,
Jul 4, 2010, 6:49:10 PM7/4/10
to
.oO(Arch)

He can be very complicated some times and there are many things where I
don't agree with him, but here he was right - your problem had _nothing_
to do with PHP.

Think about it - PHP runs on the server. The browser just receives the
HTML, without knowing how it was created. So if there's a problem in
some browser, but not in another, obviously it _can't_ be a PHP problem,
because both browsers get exactly the same markup.

Micha

Jerry Stuckle

unread,
Jul 4, 2010, 8:34:20 PM7/4/10
to

And here's your "words of the day"

CLUELESS IDIOT

Note that I was trying to be polite to you the second time. But it's no
use trying to be polite to a jack ass.

0 new messages