I am having trouble with the coding for passing. I have tried various coding suggestions, but none of them seem to work with what I need. Below is the form of the parent page. This is part of a table that lists several files. The form is a request of a file. I only show one variable that is maincategory and the name will change depending on the request. There is a form button like this for every file. This is the set up that has been part of my company and I can't change that. I am just adding the form request as a convenience rather than just asking through e-mail.
Everything works going from the parent to the child, except for passing the variables. There will be three variables for each button, and I need to change the "name" for each variable to be passed to the next page and to go in to the form. The three variables are maincategory, subcategory, and filename
99% of email clients on the user's local PC *CANNOT* handle the submitted format! This is why it is always the standard advice to use server-side code for sending emails from a web browser.
I am not having a problem with sending through e-mail
My problem isn't with the child for with sending to my e-mail. It is with the parent sending the variables. I just showed the form of the child page to show where I need to send the variables. I am trying to figure out the right function JavaScript to send my variables to the child form. The child form action is a separate action and it works. I really need help with passing variables from the parent to child.
Well, in the first place, there is no such thing in HTML as a FORM METHOD of LINK. There is only GET and POST. Now, in AJAX, I know you can use a HEAD request and some claim you can use a PUT request but, in HTML, there is only GET and POST. Have you got that straight? That is the most important thing to get through your head no matter what you might read elsewhere.
So, barring the use of server-side code, the submitting (what you call, "parent") page can use METHOD=GET to submit the values from the form elements as a query string attachment to the url specified in the ACTION attribute of the FORM. Have you got that straight? Change your METHOD to GET.
Then, in the receiving (what you call, "child") page, you can parse the content of this property to get the values passed to the second page:
alert(top.location.search);
Show me you can get that far. Then I can give you more if you want it.
I received the alert box when going to the other page. I also used the GET method first, but it didn't work with the function example I was using. I have tried many methods and functions, but none have them worked. I have a lot more coding on my pages that work also, so I understand what you are saying, I have only showed in my example the parts that I need to pass the variable to and from. Yes, I would like the rest of the code for passing the variables. I would really appreciate the help, which pertains more to my situation, since the other examples I have found don't seem to work.
I got the Method Link from someone else's example, and it worked for their example, but it didn’t for what I needed.
This is all I have, and I get an alert window, but the content parse is the part I am having trouble with. The variables are (maincategory, subcategory, and filename). The values within will change pertaining the form request button from the parent.
When you said "to submit the values from the form elements as a query string attachment to the url specified in the ACTION attribute of the FORM." I understand what you are saying here, but I need to know what the wording would be for my specific situation.
Child (or childpg_Form.html as it is referred to in the the ACTION of the FORM)
This is all I have, and I get an alert window, but the content parse is the part I am having trouble with.
I'm going to give you the content parsing function. But I want to see the actual content you're getting in the alert, first. It doesn't matter if it changes for various situations. I just want to see the alert content to confirm that you are seeing what you should be seeing.
When I create demos for clients and need to "fake" a form submit when I do not have server side access I use javascript to retreive the name/value pair values on the receiving page using the following 3 functions:
Code:
//////////////////////////////////////////////////////////////////////////////
// getParameter
//
// If page was called as an action from a form post (method="get") then
// get the value of the parameter "paramName" from the name/value parirs
// in the current URL
//
// @param paramName - name of parameter to retreive value of
// @return returnValue - value of parameter extracted from location.href
//////////////////////////////////////////////////////////////////////////////
function getParameter(paramName) {
// Build regex expression to find paramName in window.location.href
// and then parse out everything after the "=" sign and before the "&"
// sign
paramName = paramName.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+paramName+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else {
returnValue = unescape(results[1]); // Unescape it
returnValue = returnValue.replace(/\+/g, ' '); // Replace plus sign with space
return returnValue;
}
}
//////////////////////////////////////////////////////////////////////////////
// showParameter
//
// Display the results of the getParameter function at the current
// location in the document body.
//
// @param paramName - name of parameter to retreive value of
// @return paramValue - value of paramter written to the document.
//////////////////////////////////////////////////////////////////////////////
function showParameter(paramName) {
// If object exists on page with the same ID as the param name then
// copy set its value to the parameter value
copyParameterValue(paramName);
var paramValue = getParameter(paramName); // Get parameter value
document.write(paramValue); // Write to document
}
function copyParameterValue(paramName) {
var paramValue = getParameter(paramName);
if (document.getElementById(paramName) != null) {
document.getElementById(paramName).value = paramValue;
}
}
You can then use it in a page like this:
Code:
<div id="farwellMsg">
You <script>showParameter("status");</script> in completing the form.
Thank you <script>showParameter("userName");</script>
</div>
Thank you, but I don't think this is where my problem is. I am not having problems with my form submittal. It is bringing in the variables form the main page to my form on the second page. The Form on the main page is just the input button to carry the variables. I have tried codes similar to this without it working, because I need it to go into text boxes in the form on the second page. I will try this code pseudo situation without all of my other coding that are on my pages to see if it works.
Bookmarks