Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to pass/convert variable from JAVASCRIPT to PHP?
Old 06-18-2010, 05:09 AM How to pass/convert variable from JAVASCRIPT to PHP?
Novice Talker

Posts: 4
Name: One SOFAZR
Trades: 0
Hi, as mention above.. need help from whoever can help me.

Simple question but hard to get an answer(for me ),
How do i convert this .js script to php?

sample.js
Code:
<div id="live_price" style="display:none;">
<script src="myscriptsource.js" type="text/javascript">
</script>
</div>
<script src="myjsquery.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
$("div#live_price table").ready(function() {
    $("div#live_price td").each(function(index) {
        if(index==4){
            _1bulk_sell_val=$(this).text().replace('USD ','');
        }
        if(index==5){
            _1bulk_buy_val=$(this).text().replace('USD ','');
        }
    });
    var theTable = new Array(
        Array('Type','We Sell (USD)','We Buy (USD)'),
        Array('Item1',_1bullk_sell_val*0.232,_1bulk_buy_val*0.227),
        Array('Item2',(_1bulk_sell_val*0.232)/1.091,(_1bulk_buy_val*0.227)/1.118),
        Array('Item3',(_1bulk_sell_val-17)/4.72,(_1bulk_buy_val-40)/4.601),
        Array('Item4',(_1bulk_sell_val-17)/4.400,(_1bulk_buy_val-40)/4.10)
    );
    TblContent='<table>';
    $(theTable).each(function(index) {
        if(index==0){
            TblContent+='<tr><td>'+$(this)[0]+'</td><td>'+$(this)[1]+'</td><td>'+$(this)[2]+'</td></tr>';
        }else{
            TblContent+='<tr><td>'+$(this)[0]+'</td><td>'+Number($(this)[1]).toFixed(2)+'</td><td>'+Number($(this)[2]).toFixed(2)+'</td></tr>';
        }
    });
    TblContent+='</table>';
    $("div#live_price").html(TblContent);
    $("div#live_price td").css("font-weight","bold");
    $("div#live_price td").css("color","white");
    $("div#live_price td").css("font-size","9pt");
    $("div#live_price td").css("border","2px solid yellow");
    $("div#live_price td").css("background-color","blue");
    $("div#live_price td").css("text-align","center");
    $("div#live_price table").css("border-collapse","collapse");
    $("div#live_price table").css("width","100%");
    $("div#live_price").css("display","inline");
});
</script>
any idea?
FYI: I'm making an online php calculator.

Or, how to pass that sample.js variables to php? errr.. how to display sample.js result via php?

p/s:Sorry for my bad english
Thanks in advance..
__________________

Please login or register to view this content. Registration is FREE
nvxdesign is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-18-2010, 05:03 PM Re: How to pass/convert variable from JAVASCRIPT to PHP?
shivaji's Avatar
Ultra Talker

Posts: 321
Trades: 0
If you want one online calculator and you need php then I suggest to use ajax instead of Javascript.
__________________

Please login or register to view this content. Registration is FREE
- uncommon free scripts

Please login or register to view this content. Registration is FREE
- Städte, Sport, Party, Gourment, Apartments, Hotels
shivaji is offline
Reply With Quote
View Public Profile Visit shivaji's homepage!
 
Old 06-19-2010, 02:56 AM Re: How to pass/convert variable from JAVASCRIPT to PHP?
Novice Talker

Posts: 4
Name: One SOFAZR
Trades: 0
shivaji, thx for ur reply.. but the problem is, the value i need to calculate is from other server/web. Btw, thx again for replying..
__________________

Please login or register to view this content. Registration is FREE
nvxdesign is offline
Reply With Quote
View Public Profile
 
Old 06-26-2010, 01:57 AM Re: How to pass/convert variable from JAVASCRIPT to PHP?
mralokkp's Avatar
Average Talker

Posts: 16
Name: Alok Tiwari
Location: Ajmer,Rajasthan,India
Trades: 0
Check This
http://www.webcheatsheet.com/php/pas...iables_php.php
Set (Using Javascript )Variable Values in Hidden Fields of the Form being
Submitted.Use Same [$] Variable Names in php File

It's Better to use Ajax If you can.

Last edited by chrishirst; 06-26-2010 at 01:15 PM..
mralokkp is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to pass/convert variable from JAVASCRIPT to PHP?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.61505 seconds with 12 queries