Link to home
Start Free TrialLog in
Avatar of groone
groone

asked on

Transfer data of a hyperlink to a form on a different page

I've got two html files.  One is named Send and the other is named Receive.  Receive has a text box on it named myField.  Send has a link that is trying to populate myField.  It's not working.  How do I get it to work?  I want myField to have the value of the hyperlink ?myField=333333.  Here are copies of the very basic html codes.  So when receive.htm pops up it has 333333 in the text box.

=================Send======================
<html>
<head>
<title>Send</title>
</head>
<body>
<a href="receive.htm?myField=333333">This is my test</a>
</body>
</html>
==========================================

================Receive=====================
<html>
<head>
<title>Receive</title>
</head>
<body>
<input type="text" name="myField" size="20"></p>
</body>
</html>
==========================================
Avatar of pinaldave
pinaldave
Flag of India image

Hi groone,

you may need server side language to do this. like in cold fusion

<input type="text" name="myfield" size="20" value="#url.myfield#">

Regards,
---Pinal
ASKER CERTIFIED SOLUTION
Avatar of kolpdc
kolpdc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of groone
groone

ASKER

Pinaldave, huh?

kolpdc, I cannot edit the receive.htm form as it is a static form at a paging company's website.

then it will get a little bit difficult, if i understood you right. if you know its structure, you could, for example, create your own receive.htm and send its values to the script that processes the original receive.htm.
so create your own receive.htm with the same named html-form, the same fields and - with a little bit of luck - it does not require a sessionkey or something like that and you can send your own data. but that's not a nice way.
Avatar of groone

ASKER

I found something like this, but I wonder if there is a way to send to another page if I do make my own and name the form.  

===========================
<a href=javascript:void(document.forms.myForm.myField.value='3333333')>Test</a><br>

<form method="POST" name="myForm">
  <p><input type="text" name="myField" size="20"></p>
</form>
===========================

See the problem exists in that the file I am editing is in asp.  I know nothing of asp except enough to know how to trace it and locate what I am looking for.  I found the variable I need and know how to hyperlink it, but beyond that I am clueless.  What this asp file does is pull information from an sql database and creates a list.   One of the fields is that of a pager number - <%=FP_FieldVal(fp_rs,"PAGERNUMBER")%>.  I was thinking that I could somehow do something like

<a href=javascript:void(document.forms.myForm.myField.value='<%=FP_FieldVal(fp_rs,"PAGERNUMBER")%>')>Test</a> but somehow have it fill the form on the other page.  Yes, I can make another form identical in structure to the one we are trying to use.
Avatar of groone

ASKER

and yes, I am wanting to make the pagernumber a link so when they click on it, the number will bring up the form and the number will automatically be lsited in the pager form.
so if the extern page you want to address does not have a security-mechanism like a hidden session-id or something like that, you can duplicate the extern page so you can access them. just leave the address the form of the extern page calls to process the way it is.
then fill the form of the copied page with the data you want to fill in and submit the form. then the extern form-process-script should process your request.

but do not forget: if you are not directly allowed to do this, trying this could mean trouble...
Avatar of groone

ASKER

Okay, I have got this able to work
<!--
   function getID() {
       var sID="";
       var sURL = window.location.href;
       var iPos  = -1;
       var iLength = 0;
       iPos = sURL.lastIndexOf("=");
       iLength = sURL.length
       sID  = sURL.substring(iPos + 1, iLength);
       return(sID);
       //document.forms.testForm.myField.value = sID;
   }
   getID();
//-->
it returns the var just fine and can be tested with a document.write function.  This part
 document.myField.value = sID;
I can't seem to get working no matter what I do.  There error I get says that "document.myField is null or not an object"

I think if can fix this problem then my problem is solved.
i mad a mistake. forgot about the form-object.

try document.myForm.myField.value

check http://de.selfhtml.org/javascript/objekte/elements.htm if required
Avatar of groone

ASKER

same error.  Checking link.
Avatar of groone

ASKER

okay, I had to call the form first and then call the script.  Let me test it in the real application
take a look at this: http://de.selfhtml.org/javascript/objekte/elements.htm#value
the "document.write(document.Testform.Browser.value);" is interesting. give your textfield a default-value in html-code. then try to modify the script from the last sentence. so you can play with the object-hierarchy to get the right result. if it works, use it instead of document.myForm.myField.value.
(assuming the document.myform is in the same html-document!)
The answer is very easy with PHP, let me know if your server supports PHP then I can send you the code. And also your page will be much more stable without frames. Frames always cause a problem with different browser type.
frames are not the best possibility, i think, too. but sometimes you need them because design forces you. if you try to avoid javascript-code specially created my one if the big browserbuilders and orientate to the standard, there is no problem.

if you do use client-side javascript or server-side php normally does not matter. if the remote-side changes its processing-script you are lost either by this way or by this way. only advantage direct advantage (in my eyes): php cannot get switched off by a user at client-side like javascript. but that's no problem, too. just give your users a hind, that javascript is to be enabled to use the page correctly.

but phpisthefuture, how would you do? send send.htm's data to your php-script, get the post-variables and resend them post to the remote-script? could you give a hint?
>>how would you do? send send.htm's data to your php-script, get the post-variables and resend them post to the remote->>script? could you give a hint?
Yes this is exactly how I would do that. Ok I went ahead and created a page for this (to give the basic idea).
Field name is f1, user input will be manipulated with the php script;
------------------------------------------------------------------------------------------------------------
<?php
if ($submit) {         //If form submit button pressed
   $f1 = $_POST['f1'];   //Call the input from the text field
   $f1 = "<table><tr><td width=100%>".$f1."</td></tr></table>";   //Output the f1 text field  
   $f1htm = str_replace("<","&lt;",$f1);   //here's the html source code output
}
else {
}
?>
-------------------------------------------------------------------------------------------------------------
I am little bit confused with the wording of the question so I have created two alternatives;
First one; User input will be generated at the right side, and html source will be give below in the text area.
http://www.freeauctionscripts.com/crosspromotion/index5.php
Second one: User input will be generated (also adds a default URL value) and html source will be generated below.
That's what I understood from link.
http://www.freeauctionscripts.com/crosspromotion/index4.php
So you have $f1 and $f1htm variables to use wherever you like. You can send it to another page/server and manipulate it for your needs. It is almost 4 in the morning and if I am not clear enough please let me know, and if you need further description/code I will send tomorrow, please ask.
Good luck
Avatar of groone

ASKER

thank you much kolpdc.  The final script looked like this, no frames necessary -

<SCRIPT LANGUAGE="JavaScript">
<!--
   function getID() {
       var sID="";
       var sURL = window.location.href;
       var iPos  = -1;
       var iLength = 0;
       iPos = sURL.lastIndexOf("=");
       if (iPos > 0) {
          iLength = sURL.length
          sID  = sURL.substring(iPos + 1, iLength);
          document.forms.emailform.recipient.value = sID;
          return false;
          }
   }
   getID();
//-->
</SCRIPT>
you're welcome. have fun.