Page 1 of 1

b

Posted: Sat May 20, 2006 8:44 am
by boujin
gjghjg

Posted: Sat May 20, 2006 9:01 am
by timvw
Actually, the posting of a form happens at client-side... Thus you really need code for a client-side engine...

If you want to post a form at server-side you'd probably use something like curl, simpletest browser, ...

Posted: Sat May 20, 2006 9:08 am
by boujin
ghfghf

Posted: Sat May 20, 2006 9:24 am
by jayshields
No. Javascript is read by the client (like HTML) and parsed at the client's end.

If you have Javascript disabled it won't work, doesn't matter how you send it to the client.

Server-side languages such as PHP are parsed on the server and then the output is sent to the client.

Edit: I beat feyd, wooooooooooo.

Posted: Sat May 20, 2006 9:24 am
by feyd
The Javascript isn't run serverside, so no it won't work if Javascript is disabled.

I see no reason to keep the Javascript posted.

Posted: Sat May 20, 2006 11:52 am
by boujin
fghfghf

Posted: Sat May 20, 2006 12:53 pm
by Chris Corbyn
boujin wrote:So what code could I use to substitute this javascript?
All that this javascript does is submits a form. I'm struggling to see a purpose in doing that server-side, unless you're trying to complete forms on other sites from your PHP scripts?

In which case you need cURL to send POST data to the other server. Perhaps some reading up on the HTTP protocol and the 2-tier architecture would be a help:

http://en.wikipedia.org/wiki/Client/ser ... chitecture
http://en.wikipedia.org/wiki/Http#Request_methods
http://en.wikipedia.org/wiki/Http#Sample

You basically are trying to send a HTTP POST request to a server.

Posted: Sat May 20, 2006 1:20 pm
by boujin
dfgdgd

Posted: Sat May 20, 2006 1:31 pm
by Chris Corbyn
boujin wrote:I have a 100% javascript shopping cart on my web. I have had many clients complain because they had problems with it (they weren't able to "checkout" and buy on my site). I acknowledge that a percentage of them could be scams but I am sure that this was the case with many of them. My best guess is because it is made with javascript (probably because some clients have part/all of javascript disabled on their browser).

So I bought a cart made in 100% PHP (server side) but it has this only javascript code in it. So here I am trying to find a way to substitute this only javascript with some other server side language. I must say that I have basically no idea of javascript nor php (I see both very complicated) but I do have quite a good knowledge of xhtml (very easy to understand).

Apparently the javascript does this:

"calTax is a simple little function that gets called when the user selects a state; that function then re-submits the whole form back to hello.php with the state info so it can determine the tax status..."

Is there any way to make this function server side or maybe you need more information?
I think we need to think about what we're trying to acheive a little better here ;)

So far we know, the js we have here submits the form (client-side)
It executes when the user changes the state (client-side, 100% non-avoidable)
It sends data back to hello.php (presumably to recalculate tax?)

So the problem here: There's a level of user input involved which of course happens on the clinet's computer.

If you want to remove the javascript go ahead, you'll just need to place a little "Update" button (which is just another <input type="submit">) right next to the part in the form where the user changes the state.

Personally I'd keep the javascript and just add the update button (maybe even in a <noscript> tag) to the form. This way if the user has JavaScript they will get an enhanced experience with the form, otherwise they'll just have an extra click to make.

To summarise, you can't have the server respond to user input without something happen on the client-side.

Good luck :)

Posted: Sat May 20, 2006 3:39 pm
by timvw
If i understand it right, somewhere there is a event that calls the calTax() function...

If you simply add a <input type='submit' ... /> button to your form you can let the users post their data...