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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using JavaScript writing to a DB

Status
Not open for further replies.

Byager

Programmer
Oct 14, 1998
10
US
I need to be able to pass a variabl to a CF variable or write to a DB in a JavaScript. I've been told the sencond is the easier. So can any help me out? I am going to post some code and the variable "ip" is what I want to post to a single field database. Here is the code:<br>
<br>
&lt;script&gt;<br>
&lt;!--<br>
<br>
<br>
MA1=java.net.InetAddress.getLocalHost(); <br>
MA2=java.net.InetAddress.getLocalHost(); <br>
host=MA1.getHostName(); <br>
ip=MA2.getHostAddress();<br>
<br>
<br>
//--&gt;<br>
&lt;/script&gt;<br>
<br>
Can someone help me post "ip" to a database? Any help will be greatly appreciated.<br>
<br>
Thank you in advance,<br>
<br>
Brian Yager<br>
byager@logsa.army.mil
 
I'm not really expert on Javascript, but I know that you can get the remote address directly in Cold Fusion using the CGI envirionment variable #CGI.REMOTE_ADDR#. You can also get the host name using #CGI.REMOTE_HOST#.
 
You can also use WDDX to pass variables back and forth between Javascript and ColdFusion. Check out the CFWDDX tag. (In CF4.0 only).
 
Yet another possibility:<br>
You could use javascript to forward them to a CF page with ip in the addr. Example script below:<br>
<br>
&lt;script&gt;<br>
&lt;!--<br>
<br>
<br>
MA1=java.net.InetAddress.getLocalHost(); <br>
MA2=java.net.InetAddress.getLocalHost(); <br>
host=MA1.getHostName(); <br>
ip=MA2.getHostAddress();<br>
window.location='<br>
//--&gt;<br>
&lt;/script&gt;<br>
<br>
This will perform an auto-forward to the Cold Fusion page, you would have to set up your entire page there, but I KNOW it will submit the info to Cold Fusion for you :)
 
Yet another possibility:<br>
You could use javascript to forward them to a CF page with ip in the addr. Example script below:<br>
<br>
&lt;script&gt;<br>
&lt;!--<br>
<br>
<br>
MA1=java.net.InetAddress.getLocalHost(); <br>
MA2=java.net.InetAddress.getLocalHost(); <br>
host=MA1.getHostName(); <br>
ip=MA2.getHostAddress();<br>
window.location='<br>
//--&gt;<br>
&lt;/script&gt;<br>
<br>
This will perform an auto-forward to the Cold Fusion page, you would have to set up your entire page there, but I KNOW it will submit the info to Cold Fusion for you :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top