473,486 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

using javascript function in php function??

Can anyone see why the checkbox in the code below doesnt get ticked when the
textbox is changed
***This javascript function is called in the textbox's onchange event to
check it when it is changed*****

<script type="text/JavaScript">
function changed(x){
document.getElementById(x).checked=true;
}
</script>
******This php function determine whether the check box is shown or not
(actually does more than this but ive slimed down the code) and has the
javascript function in the onChange event of the echoed textbox

function editable($edfield,$unedfield,$xtratext,$selquest){
if($unedfield!==''){
echo $xtratext."<input type='text' class='BodyText' style='WIDTH:
85%' name='".$edfield."' onChange='changed(".$selquest.")>'
value='".$unedfield."'><br>" ;
}else{
echo '';
}
}

************The code below displays the check box to be ticked and the text
box (or blank) fron the execution of the php function (editable)*********

<input name="changed[]" type="checkbox" id="<?php echo $QuestionIndex; ?>"
value="<?php echo $QuestionIndex; ?>">
<?php editable($groupcount,'question',$Question,1,'') ?>

I suspect it could be due to using a javascript function in php function.
I'm not sure if this is allowed. If anyone can see what wrong Id be very
grateful

Thank Ian
Oct 12 '06 #1
4 2368
mantrid wrote:
I suspect it could be due to using a javascript function in php function.
I'm not sure if this is allowed.
JavaScript and PHP have *nothing* to do with one another.
(Read this http://xkr.us/js/clientserver three times so that you
understand it.)

PHP produces X/HTML. The web browser sees that code. Now JavaScript
comes into play.

View Source on your web page to see what code is actually coming out,
and then you will see why your HTML may or may not be broken. That's
all the browser cares about.

Oct 12 '06 #2
I know you can echo javascript but you have to make sure its placed in
the body because some of the java script doesnt work in the header. I
used php to echo(print it) javascript for a photogallery. if you want
any of the code to see what it looked like i can send it to you. if you
cant see if you can do what the guy above me said and see if you can
just test the java script or see what teh html out put is. any
questions just message me if you have any more questions.

Oct 12 '06 #3
Phrogz wrote:
mantrid wrote:
I suspect it could be due to using a javascript function in php function.
I'm not sure if this is allowed.

JavaScript and PHP have *nothing* to do with one another.
(Read this http://xkr.us/js/clientserver three times so that you
understand it.)

PHP produces X/HTML. The web browser sees that code. Now JavaScript
comes into play.

View Source on your web page to see what code is actually coming out,
and then you will see why your HTML may or may not be broken. That's
all the browser cares about.
You may also want to use Mozilla's Web Developer Toolbar, it's very
helpful in debuging JavaScript code.

Hope this helps.

Oct 12 '06 #4
OK
I got it just a silly typo error in my function. It should be

echo $xtratext."<input type='text' class='BodyText' style='WIDTH: 85%'
name='".$edfield."[]' value='".$unedfield."'
onChange='changed(".$selquest.")'><br>" ;

or for a text area (later part of the function not shown)

echo $xtratext."<textarea class='BodyText' style='WIDTH: 98%'
name='".$edfield."[]'
onChange='changed(".$selquest.")'>".$unedfield."</textarea><br>";

Thanks all for your time

Ian

"mantrid" <ia********@virgin.netwrote in message
news:2Z****************@newsfe7-win.ntli.net...
Can anyone see why the checkbox in the code below doesnt get ticked when
the
textbox is changed
***This javascript function is called in the textbox's onchange event to
check it when it is changed*****

<script type="text/JavaScript">
function changed(x){
document.getElementById(x).checked=true;
}
</script>
******This php function determine whether the check box is shown or not
(actually does more than this but ive slimed down the code) and has the
javascript function in the onChange event of the echoed textbox

function editable($edfield,$unedfield,$xtratext,$selquest){
if($unedfield!==''){
echo $xtratext."<input type='text' class='BodyText'
style='WIDTH:
85%' name='".$edfield."' onChange='changed(".$selquest.")>'
value='".$unedfield."'><br>" ;
}else{
echo '';
}
}

************The code below displays the check box to be ticked and the
text
box (or blank) fron the execution of the php function (editable)*********

<input name="changed[]" type="checkbox" id="<?php echo $QuestionIndex; ?>"
value="<?php echo $QuestionIndex; ?>">
<?php editable($groupcount,'question',$Question,1,'') ?>

I suspect it could be due to using a javascript function in php function.
I'm not sure if this is allowed. If anyone can see what wrong Id be very
grateful

Thank Ian


Oct 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
20266
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
6
1979
by: Alex Fitzpatrick | last post by:
Just by way of introduction, I'm currently the principal developer and maintainer of the a JavaScript editor plug-in for Eclipse. https://sourceforge.net/projects/jseditor/ The plug-in as it...
1
567
by: Mike | last post by:
When trying to compile (using Visual Web Developer 2005 Express Beta; frameworkv2.0.50215 ) the source code below I get errors (listed below due to the use of ICallBackEventHandler. Ultimately I...
0
6412
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
2
3031
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
7
10967
by: C.Joseph Drayton | last post by:
I have a problem that I am hoping someone can help me with. First let me describe the problem. I have an HTML form that in one field has an onBlur call to a JavaScript function. When you exit the...
2
1491
by: Daz | last post by:
Hi everyone. Sorry for the confusing subject, I couldn't think how best to word it. What I would like to know, is if there is an equivilant to this code, in using JSON. <script...
7
5041
by: Darko | last post by:
Hello, I have this particular problem with eval() when using Microsoft Internet Explorer, when trying to define an event handler. This is the code: function BigObject() { this.items = new...
3
3441
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
0
4895
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I want to call RDP on Page load and it is working fine.My code is in C#. But I am unable to perform following functions 1. when i disconnected from RDP, i want to go back to...
0
7105
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
7180
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
6846
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
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5439
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
4870
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
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.