Click to See Complete Forum and Search --> : Help Please - Using JavaScript to trap string


clyde
07-02-2003, 02:21 PM
Below is a sample of an HTML I am using to get Credit card validation.

When the Submit Button is hit the string is sent to the server In return a Text string seperated by commas is sent back.

Example String -> 1,1,1,Approved,212.41,CC Etc. Etc.

Is There any way that via JavaScript can force the html to wait for the response and trap the character string to seperate
and pass down to a server application.

Any Help would be appreciated.

Thanks
Clyde

----------------------------------------------------------------
Sample HTML


<html>

<head>

</head>

<body>

<FORM method=post action="https://xxxxx.xxxxx.net./xxxxxx/xxxxxx.dll">

<INPUT type="hidden" name="x_Login" value="xxxxxxxx">

<INPUT type="hidden" name="x_Password" value="xxxxxxxx">

<INPUT type="hidden" name="x_Version" value="63.0">

<INPUT type="hidden" name="x_Test_Request" value="TRUE">

<INPUT type="hidden" name="x_Card_Num" value="9999999999999999">

<INPUT type="hidden" name="x_Amount" value="212.44">

<INPUT type="hidden" name="x_Method" value="CC">

<INPUT type="submit" value="Click to Submit">

</FORM>

</body>
</html>

Jona
07-02-2003, 02:29 PM
You mean an onSubmit function that processing the form before sending it to the server?

[J]ona

clyde
07-02-2003, 02:33 PM
The String is being sent back to me from the payment server.

It appears on the browser as a string seperated by commas.

No html just text string.

Jona
07-02-2003, 02:36 PM
So you want to parse the string once it is returned from processing on the server? You'd set a Javascript variable to hold the value returned. For example, if you were using CGI (I know you're using C but CGI works well with C), something like this may work:


<script type="text/javascript">
var server_parsedArray = "$variable_returned_from_server".split(",");
alert(server_parsedArray);
</script>


[J]ona

clyde
07-02-2003, 02:44 PM
Iam Familar with Java Script.

I can see what you are trying to show me.

Refering to the example of HTML, At what point would the java script be put to force the html to wait for the response.

Please excuse my lack of experience.

Clyde

Jona
07-02-2003, 02:56 PM
Originally posted by clyde
Please excuse my lack of experience.

Nobody is perfect. ;)
How are you retreiving the variable into Javascript from the server?

[J]ona

clyde
07-02-2003, 03:01 PM
You Have Hit the nail on the head.

I do not know how to to trap the returning string.

Right now it just appears on my browser, as 1,1,1,authorized, Etc.

If the html would wait for the response and put the string into some kind of variable, I could use it.

I am so confused.

Clyde

Jona
07-02-2003, 03:06 PM
Originally posted by Dave Clark
Cross-posted:

http://forums.webdeveloper.com/showthread.php?s=&threadid=12110

To answer your question Jona... That is the part that is the trouble -- getting the server response into a client-side JavaScript variable. The client-side JavaScript solution (which isn't a good one -- and that is what I said in the other forum), involves the use of a hidden IFRAME, the onload event, and the innerHTML property to retrieve the data.

Didn't see that it was cross-posted.

I was trying to provide the server-side solution, by putting the variable into a JavaScript variable, which can be parsed via the split() method. If the server-side script prints the result to the page, it should be able to print the plain text into a JavaScript variable, true?

[J]ona

Jona
07-02-2003, 03:16 PM
Originally posted by Dave Clark
That server-side code cannot be modified by this questioner.

Meaning... This cannot be accomplished? Or the server isn't printing the results to the page as a variable?

[J]ona

Jona
07-02-2003, 04:15 PM
All right, I see. Thanks for the explanation there. Got kinda' confusin' for me. :)

[J]ona