[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 838
  • Last Modified:

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
0
TeamLink
Asked:
TeamLink
  • 5
  • 4
1 Solution
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now