/    Sign up×
Community /Pin to ProfileBookmark

Post Javascript variables to hidden Php iFrame

How to send javascript variables to a hidden PHP iFrame? I need to be able to access the javascript variables using PHP on the iFrame.

My Javascript vars that I need posted are like

var dstdate = dstime + 1;
var finalTime = time / 10;

And they go to a iframe Webtime.php

Sample code welcome.

Thanks

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@mityaJun 30.2009 — If you're sending your vars via a form, just set your form's target property to the name of the iframe.

Otherwise, just put the following in your JS:

[CODE]nameOfIframe.location.href = 'script.php?var1='+var1+'&var2='+var2; //etc[/CODE]
Copy linkTweet thisAlerts:
@simoraauthorJun 30.2009 — Thanks Mitya:

I guess I need an AJAX solution since I'm not using a submit button, and I'm not refreshing the page. I saw this AJAX code snip that posts form fields to a frame without refresshing the page.

[CODE]
var agevalue=document.getElementById("myform").agefield.value //get value to post from a form field
var poststr = "name=" + encodeURI(namevalue) + "&age=" + encodeURI(agevalue)
[/CODE]


How can I modify it to post a variable that's not in a form field.

Hope I explained what I'm trying to do clearly.

Thanks
×

Success!

Help @simora spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...