473,803 Members | 3,448 Online
Bytes | Software Development & Data Engineering Community
+ 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.getEle mentById(x).che cked=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($edfie ld,$unedfield,$ xtratext,$selqu est){
if($unedfield!= =''){
echo $xtratext."<inp ut type='text' class='BodyText ' style='WIDTH:
85%' name='".$edfiel d."' onChange='chang ed(".$selquest. ")>'
value='".$unedf ield."'><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($group count,'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 2385
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."<inp ut type='text' class='BodyText ' style='WIDTH: 85%'
name='".$edfiel d."[]' value='".$unedf ield."'
onChange='chang ed(".$selquest. ")'><br>" ;

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

echo $xtratext."<tex tarea class='BodyText ' style='WIDTH: 98%'
name='".$edfiel d."[]'
onChange='chang ed(".$selquest. ")'>".$unedfiel d."</textarea><br>";

Thanks all for your time

Ian

"mantrid" <ia********@vir gin.netwrote in message
news:2Z******** ********@newsfe 7-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.getEle mentById(x).che cked=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($edfie ld,$unedfield,$ xtratext,$selqu est){
if($unedfield!= =''){
echo $xtratext."<inp ut type='text' class='BodyText '
style='WIDTH:
85%' name='".$edfiel d."' onChange='chang ed(".$selquest. ")>'
value='".$unedf ield."'><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($group count,'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
20348
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()', this.pinginterval); - but is there no way to do this without using the literal ObjectName? If I write 'this.methodName()' I get "Line 1 Char 1: Object doesn't support this property or method." in IE, and nothing happens in Firebird.
6
2018
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 stands supports syntax highlighting and outlining of functions, classes and their methods.] When I took over the project in June it was for the purpose of adding outlining facilities for JavaScript written in an OO style with classes and so on. I...
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 want to use a callback from the client side to update webcontrols based on user input without using postback. I am seeking a way to stop the compile errors. using System; using System.Data;
0
6441
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 be modified: if(e.CommandName =="Print") { string parsedreceipt = null; parsedreceipt = DecodeReceipt (e.Item.Cells.Text); Session = parsedreceipt;
2
3062
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 what I'm hoping to achieve. I've never before had to use Javascript closures, but now I do, so I'm making an effort to understand them. I've been giving this essay a re-read: http://jibbering.com/faq/faq_notes/closures.html
7
10983
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 field, it calls the JavaScript routine, which in turn calls a PHP script. The PHP script runs returns the value needed. And returns to the JavaScript. The JavaScript function is then supposed to set alerts depending on the values returned from...
2
1514
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 type="text/javascript"> function makeTable(number_of_rows) { var table = document.createElement('table'); table.border = 1;
7
5066
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 Array(); this.values = new Array();
3
3474
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 want to extract all the tracks from a specific CD. Right now, im using an array to stock all the data but its just a question of time before everything blows up because of the size of the array. Thats why im want to use an XML file (later i will...
0
4927
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 previous page 2. If RDP is opened in fullscreen mode, then onconnected, i want to go back to previous page.
0
9564
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10548
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10316
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5500
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.