Click to See Complete Forum and Search --> : Debug Help!
SoCalMacDude
04-08-2003, 02:34 PM
The goal of this script is to be able to pop up a cable style of T2-Gray Cable, for example, and have it choose the T2GrayResults.html response page, then pass the "-Response" value on to lasso.
I have made 2 search pages, one with the response page hard coded, and one that depends on the Javascript to set the value.
Hard Coded:
http://www.flandersco.com/mpcablesearch1.html
JavaScript version:
http://www.flandersco.com/mpcablesearch.html
If you use the default motorcycle, there are no records in the database, and you get the Lasso diagnostic error page (I pulled my error page), so you can see the Response page that Lasso plans to send back to the browser, which should be T2GrayResults.html.
If you want to see some actual results, search for Honda 250 1995. But this shows up using the wrong response page.
Any help with debugging this would be greatly appreciated!
Thanks,
Ken
P.S. I probably made a bonehead move in the implementation of Jona's beautiful script! ;-)
You have to have this tag somewhere in the form:
<input type="hidden" name="response">
SoCalMacDude
04-08-2003, 03:19 PM
Thanks for the response!
Still not quite there.
My html tool wants to change it to:
<input type="hidden" name="response" value=value>
here: <http://flandersco.com/MPCableSearchValue.html>
and I get lasso's response page as "value"
but I edited it with a text editor, here:
<http://flandersco.com/MPCableSearch.html>
but still does not give the correct value for response.
Thanks,
Ken
I could be wrong, but I think Javascript is seeing your "-" in front of "response" as a minus sign. So you should change the name of the hidden field to "response" and the code without the dash. Try that... I'm gonna do some quick testing for ya'...
The below alerts the value of a hidden input field named "ink." It then changes the value of that field from "qwerty" to "ugh" and then alerts the new value of the hidden field:
<html><head>
<script>
function foo(){
alert(document.forms[0].ink.value);
document.forms[0].ink.value="ugh";
alert(document.forms[0].ink.value);}
</script></head><body>
<form>
<input type="hidden" value="qwerty" name="ink">
<input type=button value="Click" onClick="foo()">
</form></body></html>
SoCalMacDude
04-08-2003, 04:46 PM
The syntax required for Lasso to understand that it is the response page value, is "-Response", with the dash. I tried it both ways, with no difference in the results (both were wrong!).
So, how do we get the dash in, and is that the problem? The value did show "value" but that was basically hard coded.
Any thoughts?
Thanks,
Ken
Okay, here's what you do. Name the hidden field, "-Response" But in your function use document.formName.elements[x].value where x is equal to the number that the response field is. E.g.:
<form name="FORM">
<input type=text>
<input type=text>
<input type=hidden name="-Response">
</form>
To access the above hidden element, you'd use: document.FORM.elements[2].value because Javascript starts counting at zero, elements[0] would be the first text field.
SoCalMacDude
04-08-2003, 06:30 PM
Great idea on the "-response"!
I think i did it correctly, but still don't get the desired result! :-(
More Ideas?!?
You sure your Lasso is working right?
SoCalMacDude
04-08-2003, 06:41 PM
If I hard code the value for -response, it works perfectly!
Check it out:
http://flandersco.com/MPCableSearchHC.html
The Response is T2CableResults.html.
SoCalMacDude
04-08-2003, 07:34 PM
Here's the relevent code:
<head>
<script>function chk(){
box = document.forms[0].SearchCat[document.forms[0].SearchCat.options.selectedIndex].value;
if(box=="StdReplacementCable"){
document.forms[0].elements[3].value="StdReplCable.html"
}
else if(box=="T2-GrayCable"){
document.forms[0].elements[3].value="T2GrayResults.html"
}
else if(box=="FlanUsedinKit"){
document.forms[0].elements[3].value="MPThrottleKitResults.html"
else{ //final result
document.forms[0].elements[3].value="thelastpage.html"
}
}</script>
</head>
<Body>
<form>
<INPUT TYPE=hidden NAME="-database" VALUE="database1.fp5">
<INPUT TYPE=hidden NAME="-layout" VALUE=Cables2>
<INPUT TYPE=hidden NAME="-NoResultsError" VALUE="MPCableError.html">
<INPUT TYPE=hidden NAME="-response">
<SELECT NAME=SearchCat onchange="chk()">
<OPTION VALUE=StdReplacementCable>Std Replacement Cable
<OPTION VALUE="T2-GrayCable">T2 - Gray Cable
</SELECT>
</form>
</body>
Anybody see the problem?
Thanks,
Ken
This part:
else if(box=="FlanUsedinKit"){
document.forms[0].elements[3].value="MPThrottleKitResults.html"
Where is the last }? It should be:
else if(box=="FlanUsedinKit"){
document.forms[0].elements[3].value="MPThrottleKitResults.html";}
SoCalMacDude
04-09-2003, 01:47 PM
You nailed it, Jona!!:D
It was that one little bracket that prevented the whole thing from working! (I know, welcome to the world of programming!)
Thanks again. This is an awesome script!
Ken
You'll soon realize that the most common errors in Javascript made by most programmers (or at least... me :eek:) is syntax errors. It becomes an extreme problem when you have an enormous amount of else if's and multiple functions... Then you don't realize you're missing a bracket, you get an error "Object Expected" usually, and you don't know why... A common error. An example of a (now fixed) syntax error I had that matched the above scenario would be at: http://geocities.com/god_loves_07/names.html
SoCalMacDude
04-09-2003, 06:47 PM
I see what you mean!
Thanks again for all your help.
Ken