Connecting Tech Pros Worldwide Forums | Help | Site Map

arrays and Safari

Pasquale
Guest
 
Posts: n/a
#1: Jul 23 '05
With the code below, can anyone see why the array and/or the field in
the last line are empty for Safari users? It works with Netscape 6 and
up, IE 6, Firefox, Konqueror.

Thanks,
Pasquale


//begin

snip...

var formobj = document.forms['iregevtslct'];
var choicecount = 0;
var regsubevtarray = new Array();
var regsubevtcnt = formobj.elements['regsubevt'].length;
for (var i = 0; i < regsubevtcnt; i++) {
if (formobj.elements['regsubevt'][i].checked) {
choicecount++;
regsubevtarray.push(formobj.elements['regsubevt'][i].value);
}
}
formobj.elements['regsubevtarrayfld'].value = regsubevtarray;

snip...

//end


ASM
Guest
 
Posts: n/a
#2: Jul 23 '05

re: arrays and Safari


Pasquale a ecrit :[color=blue]
>
> With the code below, can anyone see why the array and/or the field in
> the last line are empty for Safari users?[/color]

I don't know :-)
Safary won't understand array.push ?

But, if you didn't, try using your "choicecount"

if (formobj.elements['regsubevt'][i].checked) {
regsubevtarray[choicecount] = formobj.elements['regsubevt'][i].value;
choicecount++;
}
[color=blue]
> var formobj = document.forms['iregevtslct'];
> var choicecount = 0;
> var regsubevtarray = new Array();
> var regsubevtcnt = formobj.elements['regsubevt'].length;
> for (var i = 0; i < regsubevtcnt; i++) {
> if (formobj.elements['regsubevt'][i].checked) {
> choicecount++;
> regsubevtarray.push(formobj.elements['regsubevt'][i].value);
> }
> }
> formobj.elements['regsubevtarrayfld'].value = regsubevtarray;[/color]

--
************************************************** *****
Stéphane MORIAUX et son vieux Mac
************************************************** *****
RobG
Guest
 
Posts: n/a
#3: Jul 23 '05

re: arrays and Safari


Pasquale wrote:[color=blue]
> With the code below, can anyone see why the array and/or the field in
> the last line are empty for Safari users? It works with Netscape 6 and
> up, IE 6, Firefox, Konqueror.
>
> Thanks,
> Pasquale
>
>
> //begin
>
> snip...
>
> var formobj = document.forms['iregevtslct'];
> var choicecount = 0;
> var regsubevtarray = new Array();
> var regsubevtcnt = formobj.elements['regsubevt'].length;
> for (var i = 0; i < regsubevtcnt; i++) {
> if (formobj.elements['regsubevt'][i].checked) {
> choicecount++;
> regsubevtarray.push(formobj.elements['regsubevt'][i].value);
> }
> }
> formobj.elements['regsubevtarrayfld'].value = regsubevtarray;
>
> snip...
>
> //end
>[/color]

I can only guess that you have something in your HTML that Safari
doesn't like. The following works fine in Safari 1.0.3 (OS X 10.2.8).

<script type="text/javascript">

function showChecked() {

var formobj = document.forms['iregevtslct'];
var choicecount = 0;
var regsubevtarray = new Array();
var regsubevtcnt = formobj.elements['regsubevt'].length;

for (var i=0; i<regsubevtcnt; i++) {
if (formobj.elements['regsubevt'][i].checked) {
choicecount++;
regsubevtarray.push(formobj.elements['regsubevt'][i].value);
}
}
formobj.elements['regsubevtarrayfld'].value =
regsubevtarray.join('\n');
}

</script>

<form name="iregevtslct" action="">
<input type="checkbox" name="regsubevt" value="cb_01">cb_01<br>
<input type="checkbox" name="regsubevt" value="cb_02">cb_02<br>
<input type="checkbox" name="regsubevt" value="cb_03">cb_03<br>
<input type="button" value="Show checked" onclick="
showChecked();
"><br>
<textarea name="regsubevtarrayfld" cols="50" rows="20"></textarea>
</form>


--
Rob
Pasquale
Guest
 
Posts: n/a
#4: Jul 23 '05

re: arrays and Safari




RobG wrote:[color=blue]
>
> I can only guess that you have something in your HTML that Safari
> doesn't like. The following works fine in Safari 1.0.3 (OS X 10.2.8).
>[/color]
There doesn't seem to be anything out of the ordinary with my HTML.

I was wondering if you or someone could go to the link below and tell me
if and what error messages you get, or what you notice happening?

It would be much appreciated!

If you do try it, can you select 2 or 3 events to register for and
submit it? On the next page, which is a form page that you don't need to
fill out, it should list the events you checked off at the top and a
balance owing at the bottom.

Thanks!

https://www.sub10events.com/regselect.php?regtype=i

The link is usually in a window.open without a toolbar, address bar.

Pasquale
Guest
 
Posts: n/a
#5: Jul 26 '05

re: arrays and Safari




RobG wrote:[color=blue]
>
> I can only guess that you have something in your HTML that Safari
> doesn't like. The following works fine in Safari 1.0.3 (OS X 10.2.8).[/color]

FYI...

I got my hands on a Mac and after looking and looking through my code I
noticed it doesn't seem to have anything to do with JavaScript.

When I go to the event selection page with checkboxes to select the
events I want to register for, the submit button has the value of
"Continue" and the name of "request". My PHP script checks for the value
of "request" and produces a form for personal information with the list
of selected events at the top, which it does. The form is to also have a
submit button at the bottom named "request" and the value "Submit".
However, for some reason, Safari will give it the value "Continue". So,
when I submit my personal information with the "Continue" button instead
of "Submit", it produces the form I just filled in again with no list of
selected events, blank fields and this time with the submit button
having the proper value.

By chance, I also noticed that if I reload the personal information form
after it comes up with the wrong submit button value, it will then come
up with the correct value. Of course, that can't be expected. So for now
I have changed the name for the submit button on the event selection
page, and all is fine.

If anyone knows why this is or if it is a Safari bug, please share.

Thanks.

Closed Thread


Similar JavaScript / Ajax / DHTML bytes