473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Passing 3 javaScript parameters with php

Claus Mygind
571 512MB
When I am streaming out my html page with php code, I want to pass 3 separate parameter from a javaScript event handler to a javaScript function. It seems no matter how I set it up, the result is one variable with 3 concatenated values.

This is what I have tried so far. The first one I get (I messed up)
Expand|Select|Wrap|Line Numbers
  1. <input 
  2.    type="button" 
  3.    id  ="SearchBig" 
  4.    value="Search"
  5.  
  6.  
  7. a)   onClick="searchFunction('<?php echo $cTitle.','.$cModule.','.$cSetMode ?>');"
  8.  
  9. b)   onClick="searchFunction('<?php echo $cTitle,$cModule,$cSetMode ?>');"
  10.  
  11. c)  onClick="searchFunction('<?php echo $cTitle; ?>,<?php echo $cModule; ?>,<?php echo $cSetMode; ?>');"
  12.  
  13. d)  onClick="searchFunction('"+<?php echo $cTitle ?>+","+<?php echo $cModule ?>+,+<?php echo $cSetMode ?>+"');"
  14.  
  15.  
  16.  
How do I pass 3 separate variables with a php injection?
Mar 28 '11 #1

✓ answered by Claus Mygind

Just a matter of getting the wrappers correct.

Expand|Select|Wrap|Line Numbers
  1.             onClick="searchFunction('<?php echo $cTitle; ?>','<?php echo $cModule; ?>','<?php echo $cSetMode; ?>');"

3 1782
Banfa
9,065 Expert Mod 8TB
You get a single parameter because you put ' ... ' round the whole thing making it a single string with a comma separated list in it.

Get rid of the outside ' ... ' and any of a, b or c should work.
Mar 28 '11 #2
Claus Mygind
571 512MB
Just a matter of getting the wrappers correct.

Expand|Select|Wrap|Line Numbers
  1.             onClick="searchFunction('<?php echo $cTitle; ?>','<?php echo $cModule; ?>','<?php echo $cSetMode; ?>');"
Mar 28 '11 #3
Claus Mygind
571 512MB
Thanks I just came to the same conclusion myself.
Mar 28 '11 #4

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

Similar topics

0
by: BB | last post by:
I am calling my C++ function (in a DLL) from a python script as follows: _dllcall('add','ll','l',(var1,var2)) This works fine if the 2 parameters accepted by the function are normal "long"...
1
by: tdlogger | last post by:
Help! I’m running ado.net using sql7 with service pack 4. I’m trying to use stored procedures. When I try passing varchar type parameters it comes back with 0 transactions. If I pass int...
3
by: VM | last post by:
Can collections help me pass several parameters to a method? For example, I need to pass 10 different string and integer values to one method. How would I declare a Collections type, store these 10...
7
by: Oleg Konovalov | last post by:
Hi, I am trying to pass a bunch of checked checkboxes (Javascript array) from page1 to the Java action class on subsequent web page (page2). (on page 1 I have a bunch of DB rows with a checkbox,...
1
by: SpiderSwamy | last post by:
Hi all, I want to pass the value of a field from 1.asp to 2.asp like SSO ID: 123456 this field is there in 1.asp and 2.asp do the form validation and SSO ID: field is there in the 2.html I...
1
by: Iain Adams | last post by:
Hey I am trying to pass some parameters into a javascript function. This function is invoked from an onClick from a hyperlink. The parameters are some id's for a database, most of these are just...
2
by: suneet.taparia | last post by:
Hi, On IE7 I'm using a script: function saveValues() { var validateOK=true; if (typeof validate !='undefined') validateOK = validate(document.EditForm);
4
by: softwaregeek | last post by:
hi to all, I am having some problem in passing parameter..... My code looks like::: request.setAttribute("game",game);...
1
by: rizzie | last post by:
Hi, I need some help here.. I would like to pass parameters from 1 js file to another js file. My code works with IE browser unfortunately not in Firefox, why is that? Below are the sample...
8
by: Yansky | last post by:
If I have the following function: function foo(){ alert('hi'); } and I don't need to pass any parameters to it, is calling it this way:
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...

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.