×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Using JavaScript writing to a DB

Using JavaScript writing to a DB

Using JavaScript writing to a DB

(OP)
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:

<script>
<!--


MA1=java.net.InetAddress.getLocalHost();
MA2=java.net.InetAddress.getLocalHost();
host=MA1.getHostName();
ip=MA2.getHostAddress();


//-->
</script>

Can someone help me post "ip" to a database? Any help will be greatly appreciated.

Thank you in advance,

Brian Yager
byager@logsa.army.mil

RE: Using JavaScript writing to a DB

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#.

RE: Using JavaScript writing to a DB

You can also use WDDX to pass variables back and forth between Javascript and ColdFusion. Check out the CFWDDX tag. (In CF4.0 only).

RE: Using JavaScript writing to a DB

Yet another possibility:
You could use javascript to forward them to a CF page with ip in the addr. Example script below:

<script>
<!--


MA1=java.net.InetAddress.getLocalHost();
MA2=java.net.InetAddress.getLocalHost();
host=MA1.getHostName();
ip=MA2.getHostAddress();
window.location='http://www.your.URL/CFpageURL?ip='+ip;

//-->
</script>

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 :)

RE: Using JavaScript writing to a DB

Yet another possibility:
You could use javascript to forward them to a CF page with ip in the addr. Example script below:

<script>
<!--


MA1=java.net.InetAddress.getLocalHost();
MA2=java.net.InetAddress.getLocalHost();
host=MA1.getHostName();
ip=MA2.getHostAddress();
window.location='http://www.your.URL/CFpageURL?ip='+ip;

//-->
</script>

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 :)

RE: Using JavaScript writing to a DB

Oops, looks like it did a "double-submit" on me there!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close