473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Hidden field two jumps

I want to have a window pop up with a form. When the form is submitted,
it needs to pass along the URL of the original window. If find on th
web eight gazillion descriptions of how to pass data from one page to
another via hidden fields, but not a word about how to pass that data a
second time.

I find that

<SCRIPT LANGUAGE="JavaScript"><!--
document.write(document.referrer);
//--></SCRIPT>">

will write the URL to the page.

<input type="text" value= "<SCRIPT LANGUAGE="JavaScript"><!--
document.write(document.referrer);
//--></SCRIPT>">

will place the referrer URL in a visible window, so

<input type="hidden" value= "<SCRIPT LANGUAGE="JavaScript"><!--
document.write(document.referrer);
//--></SCRIPT>">

should place the referrer in the hidden field.

But in both cases, the form does not pass the value on. It just passes
"<SCRiPT LANGUAGE="JavaScript..." etc. The browser accepts that as text,
but not as an element inside a form.

I also tried using document.write statements to write the entire form.
The browser doesn't believe it's a form.

So, how do I create a hidden form field with data from the referring
window?
Oct 6 '06 #1
2 2175
It's

<script type="text/javascript"></script>

not

<SCRIPT LANGUAGE="JAVASCRIPT"></SCRIPT>

That screaming and it's not declaring the type of script...

Secondly, never use document.write... it's an old school API that's
only there so your old old old apps don't break.

Third,

If you want to put something in a hidden field do this...

<script type="text/javascript">
<!--
window.onload = function(evt) {
var data;
data = ''; // whatever
document.getElementById('hMyData').value = data;
}
// -->
</script>

<input type="hidden" name="hMyData" id="hMyData" />

Fourth... you may want to look into server-side scripting (PHP, ASP.NET
2.0, etc...)

Bill Steele wrote:
I want to have a window pop up with a form. When the form is submitted,
it needs to pass along the URL of the original window. If find on th
web eight gazillion descriptions of how to pass data from one page to
another via hidden fields, but not a word about how to pass that data a
second time.

I find that

<SCRIPT LANGUAGE="JavaScript"><!--
document.write(document.referrer);
//--></SCRIPT>">

will write the URL to the page.

<input type="text" value= "<SCRIPT LANGUAGE="JavaScript"><!--
document.write(document.referrer);
//--></SCRIPT>">

will place the referrer URL in a visible window, so

<input type="hidden" value= "<SCRIPT LANGUAGE="JavaScript"><!--
document.write(document.referrer);
//--></SCRIPT>">

should place the referrer in the hidden field.

But in both cases, the form does not pass the value on. It just passes
"<SCRiPT LANGUAGE="JavaScript..." etc. The browser accepts that as text,
but not as an element inside a form.

I also tried using document.write statements to write the entire form.
The browser doesn't believe it's a form.

So, how do I create a hidden form field with data from the referring
window?
Oct 7 '06 #2

Bill Steele wrote:
I want to have a window pop up with a form. When the form is submitted,
it needs to pass along the URL of the original window. If find on th
web eight gazillion descriptions of how to pass data from one page to
another via hidden fields, but not a word about how to pass that data a
second time.

I find that

<SCRIPT LANGUAGE="JavaScript"><!--
The language attribute is deprecated, type is required. Do not use
HTML comment delimiters inside script elements.

<script type="text/javascript">
/* script... */
</script>

document.write(document.referrer);
//--></SCRIPT>">

will write the URL to the page.

<input type="text" value= "<SCRIPT LANGUAGE="JavaScript"><!--
document.write(document.referrer);
//--></SCRIPT>">

will place the referrer URL in a visible window, so
Not in any browser I have. It appears to me that it's invalid HTML,
you are assigning the value:

"<SCRIPT LANGUAGE="

to the input's value attribute, the rest is junk. Whatever happens in
your browser is likely the result of error correction - test it in some
other browsers.

<input type="hidden" value= "<SCRIPT LANGUAGE="JavaScript"><!--
document.write(document.referrer);
//--></SCRIPT>">

should place the referrer in the hidden field.
No, it shouldn't. You can't place a script element inside the tag of
another element, it's invalid HTML. Script elements are HTML elements,
they can't be embedded inside the tags of other elements.

But in both cases, the form does not pass the value on. It just passes
"<SCRiPT LANGUAGE="JavaScript..." etc. The browser accepts that as text,
but not as an element inside a form.
Which is exactly what it should do.

I also tried using document.write statements to write the entire form.
The browser doesn't believe it's a form.
Mine does, try something like:

<script type="text/javascript">
var ref = document.referer || 'no referrer';
document.write(
'<form action="">' +
'<input type="text" value="' +
ref + '" name="referrer"></form>'
);
</script>
--
Rob

Oct 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
1
by: mark.reichman | last post by:
First off.. Thanks to Grant Wagner for help in a previous thread related to this one. I am at a total loss... I have multiple fields in a form with the same name. Lets call the fields with the...
3
by: Roy Adams | last post by:
Hi I'm reposting this question because for some reason can't post follow up question to this thread. What I'm trying to do is put the value and text from a a select in to a text field and to a...
4
by: GavMc | last post by:
Hello I am new to internet programming and wonder if anyone can help me with this.... I am trying to pass a hidden field value on a form into another field on the form so that it can then be...
2
by: Rodusa | last post by:
I have a hidden field inside one datagrid which I can't get to make it keep its state after a postback event. Look field: <input type="hidden" id="TxtHiddenItem_id" name="TxtHiddenItem_id"...
4
by: Joe | last post by:
Hello All: I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from a base class called BasePage.aspx. BasePage.aspx has no user interface but inherits System.Web.UI.Page...
4
by: AA Arens | last post by:
I use SetFocus to jump from one field to another. That works fine. But one of the focussed fields has default text and this text is selected and the cursor is on the left of it. How to have the...
5
by: pbd22 | last post by:
hi. i have a hidden iframe for uploading files. when i check the httpfilecollection on the server, it is always zero - the files never make it to the server. i know all the javascript is working...
8
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
i have a GridView and a hidden field : <asp:TemplateField Visible=false > <ItemTemplate > <asp:HiddenField Value="<%#Eval("isActive")%>" id="hidIsActive" runat=server /> </ItemTemplate>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.