Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a Javascript form input to an action page

Status
Not open for further replies.

ma701sd

IS-IT--Management
Dec 15, 2000
94
GB
Hi,

Is it possible to pass a Javascript Variable form input from one page to another.
Within the input box I have captured an X and Y co-ordinate, but is it possible to pass this to an action page to allow me to manipulate??

Anyhelp would be greatly apprecated :)
I have pasted the code for the Javascript function:

<style>
.clickablearea{cursor:hand;}
</style>
</head>

<body>
<script>
function mouseMoved()
{
var eobj,thex,they
eobj = window.event
if(eobj.srcElement.className==&quot;clickablearea&quot;)
{
thex = eobj.clientX
they = eobj.clientY
document.formname.x.value=thex
document.formname.y.value=they
}
}
document.onclick=mouseMoved
</script>

<div class=&quot;clickablearea&quot;>The clickable area that, once clicked upon populates the input box with an X and Y co-ordinate</div><br><br>

<form name=&quot;previewXYPage.cfm Mehod=&quot;Post&quot;>

<input name=x><input name=y>
<INPUT NAME=&quot;X&quot;><BR><INPUT NAME=&quot;Y&quot;><BR>


<INPUT TYPE = &quot;Submit&quot; VALUE =&quot;Enter&quot;>
<INPUT TYPE = &quot;Reset&quot; VALUE =&quot;Clear&quot;>

</FORM>
</body>
</html>
 
You might want to check out Khurram's post on 1/18 title &quot;Drop Down Box&quot; as I showed how to do this with just a select box. What you will want to do is use the form's onsubmit event handler to set &quot;self.location.href&quot; to the page you want to submit the results to. You can add on url variables for any values you need to send (see his post for example code).

Let me know if you have any problems with it but I think this will do what you want.
GJ
 
Hey GJ,

Thanks, I sussed it in the end...I needed &quot;input type=&quot;formname&quot; action=&quot;file.cfm&quot; Method=&quot;post&quot;>

I just an example from the book.

What puzzles me is that how does Input type=&quot;formname&quot; solve it???

Maybe you might know?

Regards
Sam
 
I've never seen that one before and it's not in my reference books. Is that the form tag or an input tag? I'd like to see how that works.

GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top