473,508 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript within php

77 New Member
hello all, i have a question..can script of javascript (variable of js or html form)stored within tag php or php command???

thanks


kind regards, maminx
Jul 29 '08 #1
6 1293
r035198x
13,262 MVP
Give an example of what you mean.
Jul 29 '08 #2
maminx
77 New Member
Give an example of what you mean.

the point is i need to call a javascript method within php code, but with no user interaction. i.e. no click of a button, no user input, nothing.


this is the example

i have an input form

[HTML]<input name="textfield" type="text" size="10" value="<?php echo $this->ProjectPraBp_model->getProjectPraBpDate("025");?>">
[/HTML]

there's value "025" (bold)...i want that value is from javascript variable / form html object, is it possible??

thanks

maminx
Jul 29 '08 #3
maminx
77 New Member
the point is i need to call a javascript method within php code, but with no user interaction. i.e. no click of a button, no user input, nothing.


this is the example

i have an input form

[HTML]<input name="textfield" type="text" size="10" value="<?php echo $this->ProjectPraBp_model->getProjectPraBpDate("025");?>">
[/HTML]

there's value "025" (bold)...i want that value is from javascript variable / form html object, is it possible??

thanks

maminx

is there anyone can help me with this issue??
Jul 31 '08 #4
acoder
16,027 Recognized Expert Moderator MVP
This won't be possible directly. PHP is server-side. It runs and the page finishes execution whereas JavaScript is client-side.

The way to solve your problem would be to make an Ajax request after the page loads with the JavaScript variable. However, having said that, if you already know the JavaScript value, just replace it in the PHP code.
Jul 31 '08 #5
maminx
77 New Member
This won't be possible directly. PHP is server-side. It runs and the page finishes execution whereas JavaScript is client-side.

The way to solve your problem would be to make an Ajax request after the page loads with the JavaScript variable. However, having said that, if you already know the JavaScript value, just replace it in the PHP code.

yes i think it needs ajax, and of i of course i don;t know the javascript value so i can't replace it with the php code..the value is generated with html form or variable of javascript..

But my issue now is because i'm using framework php (codeigniter), than i can't just put the ajax into the php code, there's a rule of framework..

anyway, thanks a lot

kind regards, maminx
Aug 1 '08 #6
acoder
16,027 Recognized Expert Moderator MVP
It must allow some JavaScript which you can put in the head and call when required, e.g. onclick of a button.

If that's not possible, submit the form with a hidden value and set the input value using PHP.
Aug 1 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.