Setting Form Values by Javascript in Safari on iPhone Isn't Working

We have a web based application.

As such, this is accessable on an iPhone through it's safari browser. However, there are some small parts of the system which don't work...

On the page, when clicking certain buttons, we set a hidden field which is then used to determine what happens once the form is submitted. This field is called "action" and is defined on the form as such...

<input type="hidden" name="action">

When we submit the form, we do the following before submission on  a button on the form.

onclick="this.form.action.value='Save';return formValidate()"

The "return formValidate" works perfectly, but the previous statement that sets the field value does not - or at least if it does, the value is lost when the form is submitted.

Without it, our web app doesn't know what to do!

This works on all browsers we have tested with - IE6/IE7/FF/Opera - even Safari 3 Beta on Windows, but just will not work on the iPhone. I have tried various different ways of setting that field value, but with no success.

So, does anyone have any ideas?

Thanks,

Phil
TeamLinkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Stacy SpearPresident/Principal ConsultantCommented:
Did you try the onchange event? Just wondering if it can be called a click since it is a touch screen.
0
TeamLinkAuthor Commented:
thanks, but it's not the onclick event thats the problem - the second part of the code that is on the onclick event above - the "doValidate()" works fine, so it can handle the onclick, it just seems that its the setting of the form value that isn't working.

Also, to give a bit more information - if I hard-code the action into the form... i.e...

<input type="hidden" name="action" value="Save">

...it does remember the value, so it's not losing the value on submit, it's just not being set by the onclick.

thanks,

Phil
0
Stacy SpearPresident/Principal ConsultantCommented:
Since it is calling the function, maybe instead of setting the value their, call a function that does the setting to see if that changes it. The only way I can imagine that not working is if the object reference isn't being passed properly.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

TeamLinkAuthor Commented:
Hi, thanks darkstar, but I've already tried that - and nu luck I'm afraid!

Phil
0
Stacy SpearPresident/Principal ConsultantCommented:
Is there any innerhtml going on in the form, ie you are adding some form items from javascript? I had issues with Safari and IE not liking that sometimes.
0
TeamLinkAuthor Commented:
No, theres nothing of that nature that should affect this form.
0
Stacy SpearPresident/Principal ConsultantCommented:
I'm lost then. You are revalidating once it hits the server right? Choose the action there, you can't rely on the fact that javascript is enabled, although it is on 97% of the browsers that hit our sites.
0
TeamLinkAuthor Commented:
Sorry, I am not sure what you mean by "revalidating once it hits the server".

I don't think javascript is the problem as other javascript in the system works OK on the phones browser.
0
Stacy SpearPresident/Principal ConsultantCommented:
If javascript is disabled or not setting any values, then once the form gets server-side, evaluate the same thing there. Makes it safer against hackers and a fail safe for when javascript isn't available or not working.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.