473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How could I choose between using Jscript ELSE php validation

JnrJnr
88
Hi all,
how can I choose to use JavaScript (and if not available) use PHP in this example?
I have an HTML select control that has two onchange methods. The first one calls a JavaScript validation (getValues();) and the second calls for server validation (this.form.submit();).

Expand|Select|Wrap|Line Numbers
  1. <select id="selectID" name="selectName" onchange="getValues(); this.form.submit()">
  2. <option></option>
  3. <option></option>
  4. <option></option>
  5. </select>
I only want the server validation (this.form.submit();)
to occur if javascript is disabled. Else use JavaScript
Any advice please?
Jul 15 '11 #1

✓ answered by JnrJnr

Ok well thanks for the replies and ideas.
What I did was use <noscript> tags to add a submit button to the form if there's no Jscript enabled. I guess I could make a splash page or something. (I see yahoo does that)
Its quite stupid or not understandable why an html onchange event does not work if Jscript is disabled even if the onchange event is just to submit the html form. Any ideas why?
Thanks

11 1870
Dormilich
8,658 Expert Mod 8TB
don’t do that.

always use server-side validation regardless if there was client side validation or not.
Jul 15 '11 #2
Rabbit
12,516 Expert Mod 8TB
I agree, always use server side validation. But if you want, do both, so the user can have instant feedback before submission.
Jul 15 '11 #3
JnrJnr
88
ok, I dont think I explained it correctly. Its not really validation but rather just to make the form more interactive. Lets call it functionality.
I already have server side functionality and javascript functionality. All I want to do is choose between the two. If the user has Jscript disabled then use serverside code to do the job else let Jscript do it quicker.
Is there a way I could?
Jul 15 '11 #4
JnrJnr
88
At the moment it is doing both. I only want it to do the one or the other. If it cant do Jscript then it has no choice but to do it server side.
Jul 15 '11 #5
Rabbit
12,516 Expert Mod 8TB
It would help to know what it is that you're trying to do.
Jul 15 '11 #6
JnrJnr
88
Im making a FAQs page that when you click on the question it pops out the answer. Take a look at the code above. The onchange="getValues(); this.form.submit()" is calling two methods. The first one is Jscript and the second will post the form with PHP. I want the second method to run ONLY if Jscript is not enabled.
Jul 15 '11 #7
Rabbit
12,516 Expert Mod 8TB
You'll need to set up a splash page that attempts to submit itself with javascript. If it does, you can send back a page with the javascript. If not, they will click on a link in the splash page that takes them to a page without javascript.

If you don't want to do a splash page or have them click a link to get to a non-javascript page, you could combine them both into one page. It's just a bit more complex. It would have to attempt to submit itself using javascript with a default page of using php. But if it's able to submit itself using javascript, then you can return a page using just javascript.
Jul 15 '11 #8
JnrJnr
88
Ok well thanks for the replies and ideas.
What I did was use <noscript> tags to add a submit button to the form if there's no Jscript enabled. I guess I could make a splash page or something. (I see yahoo does that)
Its quite stupid or not understandable why an html onchange event does not work if Jscript is disabled even if the onchange event is just to submit the html form. Any ideas why?
Thanks
Jul 15 '11 #9
Rabbit
12,516 Expert Mod 8TB
Because events are used to trigger scripts. Using an event to submit a page is in essence using a script to submit a page.
Jul 15 '11 #10
Dormilich
8,658 Expert Mod 8TB
Because events are used to trigger scripts.
or even more plain, Events are a JavaScript thing (=> DOM). not part of any HTML (HTML only defines attributes not the events themselves).
Jul 15 '11 #11
JnrJnr
88
Ok all good. Thanks for the replies guys
Jul 16 '11 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Al | last post by:
Hi, I am trying to add rows to a table dynamically, using JScript. Can I someone explain, how to add events to the newly added cells/ rows? Following code does not fire the onmousemove event. ...
10
by: Christopher Brandsdal | last post by:
I have this string: /sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how would I do this? In VBScript I could find the...
3
by: Andrew | last post by:
I have written a jscript that is executed when the user logs into the network. Among other things, I want the script to be able to run an executable which is stored on the network. Can anyone...
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
2
by: John Sweet | last post by:
I'm using a RequiredField validator control to do some client side validation. Client validation works fine, but the buttons do nothing after validation (in other words, the form is not posted). It...
6
by: Peter Afonin | last post by:
Hello, I'm creating an application in ASP.NET 1.1. I need to check whether at least one checkbox in my datagrid has been checked. To do this, I'm using Javascript - I'm adding this code to...
2
by: sunsoffun | last post by:
Im trying to hide a menu column using jscript. Its works as required in firefox but ie.. a big no no. Please see the code below.... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...
1
by: sunsoffun | last post by:
Im trying to hide a menu column using jscript. Its works as required in firefox but ie.. a big no no. Please see the code below.... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...
9
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I have one dll written in c#. One of its methods return array of dictionary. I want to call and use that method in ASP file. I am using jscript in ASP. my code is a s follows: <%...
1
by: vivek verma | last post by:
Solution which shows whether a number is a even or odd without using " if() , else() " and any arthamitic operater like %(modulus)
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.