Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Safari and OnChange/OnClick Etc.

Status
Not open for further replies.

Jawa

Programmer
Feb 21, 2002
74
US
Hi,

I have some simple code:

<select name="Var#ctr#" style="width: (#Len(VarientName)# + 8)px;" class="textfield" onClick="javascript: a(this.value, #ctr#);document.frmProductDetail.SKU.value = varSKU;">

Where the "document.frmProductDetail.SKU.value = varSKU;" should change the value of a text box:

<input type="text" name="SKU">

It works fine except on Safari. Any Ideas?

Thank you!!
 
1) get rid of the "javascript:" in your onclick event
2) use references such as: [tt]document.forms['frmProductDetail'].elements['SKU'].value[/tt]
3) show us code AFTER it's been generated by the browser (view > source).



*cLFlaVA
----------------------------
spinning-dollar-sign.gif
headbang.gif
spinning-dollar-sign.gif

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Could you also confirm that you have run your page code through the HTML validator at ? If it passes that, then you know your markup is valid (most problems are caused by invalid markup that one browser may handle whilst another may not).

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
I tried the new code to no avail:


<select name="Var3" style="width: (13 + 8)px;" class="textfield" onClick="a(this.value, 3);document.forms['frmProductDetail'].elements['SKU'].value = varSKU;">
<option value="0">Select Gift Set Size</option>
</select>


<input type="text" name="SKU" value="">
 
I thought onChange was not valid in Safari?

varSKU is global

The "is width: (13 + 8)px even valid?" is dynamically set. It works in all browsers so I think I am OK there.

This is so odd as it works across the board minun Safari.

Thanks!!
 
Change this:

Code:
style="width: (13 + 8)px;"

to this:

Code:
style="width: 21px;"

I'm surprised it works in any browser, to be honest.

onChange does work, and is valid in Safari.

Perhaps you are getting a JavaScript error at an earlier stage, stopping that JS from working?

Perhaps you can post a complete cut-down test harness, or a URL to your page?

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
myself said:
Could you also confirm that you have run your page code through the HTML validator at ?
You may have missed it first time.

Jawa said:
I thought onChange was not valid in Safari?
No. It's totally valid. You should consider using it without the capitalisation, however.
Cheers,
jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
All your help is greatly appreciated.

I ran the site through a validator and it does some up with a bunch of issues (216) which I need to tak up with someone here. However, none of those errors are haulting its operation on PC/IE/FF. The safari thing is the debacle.

The page in question is:


In safari the SKU switches out fidn using the get elementbyID in a DIV, but not in the text box ODD.

Thanks
 
This does work

<input type="text" name="SKU" id="SKU" onmouseover="document.forms['frmProductDetail'].elements['SKU'].value = varSKU;">
 
I ran the site through a validator and it does some up with a bunch of issues (216) which I need to tak up with someone here. However, none of those errors are haulting its operation on PC/IE/FF. The safari thing is the debacle.

There you go again, blaming Safari.

You've just admitted your site is stuffed full of errors, but aren't willing to accept the possibility that any of them might just be stopping Safari working just because other browsers don't break.

Some browsers are more tolerant than others. I strongly suggest you come up with a cut-down, absolute minimum test harness that you can show to break in Safari, [!]and which validates[/!], before attempting to fix this one.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top