...

View Full Version : Can You Grab Form Query_String before it is sent?



KrazyKid
07-31-2002, 10:45 PM
Does anyone know if you can grab query_string values before the query_string is sent?

Obviously you can determine the values of the form attributes but can you get the full value of the http request?

Hope so....

:confused:

nolachrymose
07-31-2002, 11:08 PM
function getQueryString(formObj) {
var qs=formObj.getAttribute("action");
for(var i=0;i<formObj.elements.length;i++) {
qs+=formObj.elements[i].value;
}
alert(qs);
}

Then, add it to the onsubmit event handler of the form object.

Hope that helps!

Happy coding! :)

KrazyKid
08-01-2002, 04:02 PM
Thanks for the code nolachrymose!

I did add it to the form tag but it never executes.

I am using document.forms.frmMyForm.submit();

Will this not work when using the submit() method?

Thanks again....

JohnKrutsch
08-01-2002, 04:36 PM
Are you using an onsubmit event handler in your form tag? Maybe something like this:

<form onsubmit="return getQueryString(frmMyForm)" ...

KrazyKid
08-01-2002, 04:54 PM
The form method is get..the action is set to return the funtion;

I am using one form to get values and then I wand to submit one of two forms based on the values of the 1st form...to an iframe

<parent form>
calls
form1.submit();
form2.submit();

<form1 action="get">
<form2 action="post">

two seperate methods both being called from

submit();

I think that this should be easier than it is...

JohnKrutsch
08-01-2002, 05:02 PM
I bet the whole process could be easier. Why don't you tell us what you are ultimately trying to do so we can help you out with the whole process.

KrazyKid
08-01-2002, 05:14 PM
I have a form that gets the values to be used by another form based on of the selected objects values.

if obj = "a" then form1.submit();
if obj = "b" then form2.submit();

I want the iframe to display the result output from the form querystring that is being sent...

I was thinking if I know the query_string, I could just set the iframe.location to the value of the query_string...

What is the best way to target a iframe from JavaScript.

I have tried window.framname.location = document.forms.myForm.submit();
but that doesn't work ;(

Thanks to all!

Roy Sinclair
08-01-2002, 05:37 PM
What is the best way to target a iframe from JavaScript.

document.forms.yourFormNameHere.target="yourTargetWindowOrFrameNameHere"

KrazyKid
08-01-2002, 05:49 PM
Thanks Roy! I should have tried that....

Now how do I force a submit() to display to that target??!?

JohnKrutsch
08-01-2002, 05:52 PM
You can target a specifc frame inside the form tag. For example if I wanted the final result of a form submission to aprea in a specific frame I simply add a target attribute to the form tag:

<form method="get" target="FrameNameHere" ...


then when this frame gets submitted the reults display in the frame I targeted.

KrazyKid
08-01-2002, 05:55 PM
You guys are the BEST !!! :)

Thanks again for prompt and insightful posts! :thumbsup:

KrazyKid
08-01-2002, 06:57 PM
Sorry to be such a pest..but I gotta know!

Can these be done?

1. iframe.style.visibility = "visible"
errors: style is unknown or not an object (style is set to "hidden")

2. iframe.target or location = "_blank"
errors: "Permission Denied!"

Thanks again.......

KrazyKid
08-07-2002, 09:17 PM
I was able to set the visibility of the iframe using:

document.getElementById("frameID").style.visibility='hidden';

However I am still unable to target the iframe if the frame has a URL loaded into it...

window.top.frames['frameID'].document.location.href.value ='about:blank'; //errors "Access Is Denied!"

window.top.frames['frameID'].document.target ='about:blank'; //errors "Access Is Denied!"

Is this a violation of the DOM?!?!

mordred
08-07-2002, 10:07 PM
If your document that's been loaded into your iframe does not lie in the same domain as the document that contains the iframe, and you try to access the iframe document via javascript, you are violating the so-called Same Origin Policy.

That's a very strict security feature that can't be circumvented.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum