Javascript change property of PHP variable according to date in list menu selection
I'm creating a booking form which selects prices and dates from a Mysql databse according to the code transported in the URL.
I have successfully got the form to display dates for this year and next year in a drop down menu/list form item.
However, I would like to change the price according to what year the selected date falls in.
The key variable that needs to change is this $coursefee
If a date in 2009 date (e.g. 2009-10-12) is selected the varibiable $coursefee would change to be
<?php $coursefee=$row_rs_course['price09'];?>
And if a date like 2010-10-12 is selected the varibiable $coursefee would change to be
<?php $coursefee=$row_rs_course['price10'];?>
To complicate matters the menu is dyamically populated too:
<select name="dates" class="course" id="dates">
<?php
do {
?>
<?php
$date1 = strftime("%d %b",strtotime($row_rs_dates['start_date']));
$date2 = strftime("%d %b %Y",strtotime($row_rs_dates['finish-date']));
?>
<option value="<?php echo($date1." - ".$date2); ?>"><?php echo($date1." - ".$date2);?></option>
} while ($row_rs_dates = mysql_fetch_assoc($rs_dates));
$rows = mysql_num_rows($rs_dates);
if($rows > 0) {
mysql_data_seek($rs_dates, 0);
$row_rs_dates = mysql_fetch_assoc($rs_dates);
</select>
I'm pretty sure the answer lies in the murky world of javascript but unfortunately I haven't the first clue about javascript.
Can anyone help me with this?
Cheers
Dave
Thanks David,
I can see that would work and I'd have no problems doing that but wouldn't that mean that all the oher data the user had fillled in would dissapear?
There are too many fields I think to transfer everything in the URL and the date selection field is way down the form and I think it would seem pretty odd to have it before name address etc. That's why I thought a javascript solution would be more suitable as it needn't rely on a page refresh.
Cheers
Dave
Similar Messages
-
How do I pass a username form variable from a drop down list/menu to another page?
Hi,
I have a login_success.php page that has a drop down list/menu (which lists usernames). I want the user to click on their user name, and when they click the submit button the username information to be passed over to the username.php page which will contain a recordset, sorted by username.
How do I pass the username info from the drop down list/menu to the username.php page?
The drop down menu is connected to a recordset listUsername, I have filtered the recordset with the Form Variable = username, and I have used the POST method to send the username to the page username.php. I'm not sure how to structure the php or which page to place it on.
<form id="form1" name="form1 method="post" action="username.php">
<label for="username_id">choose username:</label>
<select name="username_id" id-"username_id">
<option value="1">username1</option>
<option value="2">username2</option>
<option value="3">username3</option>
<option value="4">username4</option>
</select>
<input type="submit" name="send" id="send" value="Submit" />
<input type="username" type="hidden" id="username" value="<?php echo $row_listUsername['username']; ?>" />
</form>
Could somebody help me please?
Thanks.I would not post the variable over, In this case I personally would send it through the URL and use the $_GET method to retreve it. For Example.
<html>
<head>
<title>Test Page</title>
<script type="text/javascript">
function userID(){
//var ID = form1.userIDs.selectedIndex;
var user = form1.userIDs.options[form1.userIDs.selectedIndex].value;
window.location = "test.html?userID=" + user;
</script>
</head>
<body>
<form id="form1">
<select name="userIDs" id="userIDs" onchange="userID();">
<option>Select a User</option>
<option value="1">User 1</option>
<option value="2">User 2</option>
<option value="3">User 3</option>
<option value="4">User 4</option>
</select>
</form>
</body>
</html>
//PAGE TO RETRIEVE THE USERNAME
<?php
if(isset($_GET['userID'])
$userID = $_GET['userID'];
echo $userID;
die; -
How can I make clearer the menu highlight selections, for example when scrolling through my bookmarks. The light blue color is hard to see in Windows 7. How do I change that color?? Running FF 3.6.6
== This happened ==
Every time Firefox opened" Is there anyway I can define individually as to what color should be related to each text in ring menu?"
Well not with a ring and not programatically.
The best I can suggest is a picture ring, see below.
Ben
Message Edited by Ben on 11-18-2005 02:16 PM
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction
Attachments:
Picture Ring.JPG 5 KB -
Aggregate copy -- variable or fixed date
Hi Gurus:
When I try to copy an existing aggregate a pop up screen comes up saying 'select variable or fixed date' -- and lists
some dates.
My question is what exactly this means & if I cancel it says, this aggr may not be used because I did not select value from that screen..
pls suggest. I will be happy to assign the points.
Thanks & have a nice day ahead.I got it...
-
Changing a datagrid column image according to the datagrid column value
Flash Builder 4.5 / SDK 4.5.1.
Fairly new to Flash Builder & Flex
Application targets tablets so it's a "mobile" project.
Been beating my head up against the wall on trying to figure out how to do this. Watched videos on Lynda.com. Read Adobe "docs" till my eyes glaze over. Takes me about 2 lines of code in my corresponding .NET project doing the same thing.....
Tried numerous examples. Inline rendering, external rendering files per the examples.
I have a response field in the database and corresponding column in the s:datagrid. If the "reportInfoResponse" field is null (not answered), show an image with a question mark. If yes show an image with "Yes" on it. Same for a no answer.
I get errors of:
1120:Access of undefined property negativeAnswer.
1120:Access of undefined property affirmativeAnswer
1120:Access of undefined property reportInfoResponse
1120:Access of undefined property showResponseImage
If I put this in an external rendering file I also get an error where it can't access the datafield (reportInfoResponse). I've tried data.reportInfoResponse, {data.reportInfoResponse}, {reportInfoResponse} and just plain reportInfoResponse the external rendering file with no luck. I've tried single and double quotes around Y and N. According to all the examples (not to say there aren't more!), I should be able to reference data.reportInfoResponse in the external file and things should be fine. Of course, the examples are bare bones code and I don't have a clue if any importing of classes or other items need to take place. I never see any references of such. The examples also show the image embedding and changing the image by using imageID.source=... In my code it tells me it can't find it.
I have put (ERROR HERE...) on the lines where I'm getting the error messages. I've eliminated a lot of database scripting and such cause that's all working.
Any and all suggestions would be appreciated as I'm pulling out what little hair I have left.......and that's not much at my age........ And yes, I probably could do it by just show text in the column, but that's not what the customer wants... There are other columns I need to do this for so I figure if I can get 1 done and working, the rest are a snap. I CAN use inline or external rendering to show an image. It's the changing it that is the catch.........
Thanks in advance!
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="onCreationComplete()"
title="{whichCategoryName} > {whichSubCatName} > Questions">
<fx:Script>
<![CDATA[
import com.adobe.serializers.utility.TypeUtility;
import flash.data.SQLConnection;
import flash.data.SQLMode;
import flash.data.SQLResult;
import flash.events.StatusEvent;
import flash.filesystem.File;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.navigateToURL;
import flashx.textLayout.tlf_internal;
import mx.collections.ArrayCollection;
import mx.core.BitmapAsset;
import mx.events.FlexEvent;
import spark.events.GridEvent;
import spark.events.IndexChangeEvent;
...(lots of database coding left out here)
<s:DataGrid id="showQuestions" width="100%" height="100%"
creationComplete="Grid_creationCompleteHandler(event)" fontFamily="_sans"
gridClick="gridClickEvent(event);" horizontalScrollPolicy="off"
selectionColor="#8AD8EF" selectionMode="singleRow" sortableColumns="false"
variableRowHeight="true" verticalCenter="middle">
<s:columns>
<s:ArrayList>
<s:GridColumn visible="false" dataField="id_report" headerText="id_report" resizable="true" sortable="false"></s:GridColumn>
<s:GridColumn visible="false" dataField="id_question" headerText="id_question" resizable="true" sortable="false"></s:GridColumn>
<s:GridColumn id="col_reponse" visible="true" dataField="reportInfoResponse" headerText="Response" resizable="true" sortable="false">
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer>
<fx:Script>
<![CDATA[
[Embed(source="assets/unknown.png")]
[Bindable]
public var unknownAnswer:Class;
[Embed(source="assets/yes.png")]
[Bindable]
public var affirmativeAnswer:Class;
[Embed(source="assets/no.png")]
[Bindable]
public var negativeAnswer:Class;
(ERROR HERE - 1120:Access of undefined property reportInfoResponse)
if(reportInfoResponse == "Y")
(ERROR HERE - 1120:Access of undefined property showResponseImage)
showResponseImage.source = affirmativeAnswer;
(ERROR HERE - 1120:Access of undefined property reportInfoResponse)
if (reportInfoResponse == "N")
(ERROR HERE - 1120:Access of undefined property showResponseImage)
showResponseImage.source = negativeAnswer;
]]>
</fx:Script>
<s:Image id="showResponseImage" source="{unknownAnswer}" verticalCenter="0" horizontalCenter="0"/>
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:GridColumn>
<s:GridColumn id="col_question" visible="true" dataField="question" headerText="Question" resizable="true" sortable="false"></s:GridColumn>
</s:ArrayList>
</s:columns>
<s:AsyncListView list="{showTheseQuestions}"/>
</s:DataGrid>
</s:View>Ioan Thanks for the reply.
Probably my previous explanation of the problem was a little incomplete. Let me give a better description.
The situation is something like this.
I have a requirement in which the customer wants the column header to reflect the 'keep filter value' restriction that he does dynamically in the query report.
i.e:
-- usually the kf column header shows 'sales volume'
-- column header with text variable of the Calender year / month variable -- 'sales volume for 2000 oct'
-- but when the report is run, if the user wants to go and change the filter: calender year / month > rt clk > keep filer value > select Jan 2003.
The kf column header still shows 'Sales Volume 2000 Oct'
How to make the column header change to 'sales volume for Jan 2003' ?
Any suggestions greatly appreciated.
Thanks, -
Cannot change variable for key date in aggregate
Hello,
when I drag time-dependant attributes into an aggregates definition I am prompted to enter a key date or choose a variable for that. I then activate and fill that aggregate. Afterwards I deactivate it and remove the time-dependant attributes so there are no time-dependant attributes in the definition any longer. I then want to also remove the variable for the key date but I can't do so. This property is greyed out and there is no context menu for the entry "Variable for key date".
The SAP Help says this should be possible by changing the key date variable through the context menu (see http://help.sap.com/saphelp_nw04/helpdata/en/7d/eb683cc5e8ca68e10000000a114084/frameset.htm).
Has anyone faced this problem, too? I do not want to redefine my aggregate as this is not an elegant solution to the problem.
Thanks to any answers in advance.
Regards,
PhilippHey Karim,
Because you have time dependent attributes in the aggregate you need to specify key date:
check this
http://help.sap.com/saphelp_nw70/helpdata/en/44/70f4bb1ffb591ae10000000a1553f7/frameset.htm -
Troubles using Javascript popoup inside a PHP file
I am trying something simple: to open a popup window trough a
javascript code inside my PHP file and nothing happens: here is the
code:
$openwindow =
"MM_openBrWindow('view.html','','width=300,height=300')";
echo "<td><a href='#'><img
src='images/button_blue.jpg' alt='Map' width='97' height='13'
border='0' onclick=" . $openwindow . "/></a></td>";
Also I am declaring such Javascript function at the beginning
of the file... Please help me as soon as you can... it is driving
me crazy... thanx in advance !.oO(David Powers)
>Michael Fesser wrote:
>> print "<a
href='foo?id=$something'>bar</a>";
>>
>> Not a single escape character and very readable in
an editor with proper
>> syntax highlighting.
>
>I agree with Steve that this is a trivial example that
doesn't really
>prove anything.
OK. At least it shows that escaping is not always necessary
In a more complex example with more variables I would've used
printf().
>If $something is the only variable in a long section of
>HTML, it's much more efficient to do this:
>
><a href="foo?id=<?php echo $something;
?>">bar</a>
I don't think efficieny is really an issue here.
>Every time that the PHP engine encounters double quotes
inside a PHP
>block, the engine has to parse the content to find if any
variables are
>interpolated. In your example, there is a variable, so
the effort isn't
>wasted, but many developers use double quotes all the
time, even if no
>variable are included in strings. Although the difference
in processing
>time is only microseconds, it's an inefficient way of
writing PHP.
Did you ever encounter any performance issues just because of
using
"unneccesary" double quotes? Or by using string concatenation
instead of
the slightly faster
echo $foo, $bar, $somethingElse ?
I didn't, and I doubt I ever will. It may be not the best
style and
usually I use single quotes where possible, but I don't care
too much,
because other things are much more important.
In fact I consider that all rather esoterical. If someone
tries to
"optimize" his code by avoiding double quoted strings where
possible
then IMHO he doesn't really have understood optimization at
all. The
real bottlenecks are not some syntactical sugar provided by
PHP, but the
algorithms and I/O operations. That's where optimization has
to start.
>However, I've seen a lot of inexperienced people post
questions about
>PHP problems, usually caused by the incorrect mixture of
single and
>double quotes.
Agreed, me too. But often it's not just some lack of
knowledge, but also
the usage of the wrong tool. Many errors I've seen in
beginner's code
(especially the mentioned quoting problems) could've been
easily spotted
with proper syntax highlighting.
>When you ask why they have coded it in such a convoluted
>way, the answer is invariably "because it's a PHP page".
Hmm, quite possible.
>PHP is designed
>to be embedded in HTML.
True, but just because PHP is designed for this and that,
doesn't mean
that I always have to use it in that way. Remember
register_globals and
magic quotes - they were a fundamental part of PHP's design a
while ago.
>You can also include HTML in PHP functions.
Now it gets really nasty. That's even more ugly than heredoc
syntax. ;)
With HTML embedded in PHP functions I always had the problem
how to
indent the code - either the source code looked bad or the
final HTML.
I never did it again.
>If the HTML block contains a lot of variables or other
dynamic code, I
>agree that using print or echo is probably more efficient
and easier to
>read. However, when HTML is predominant, embed the
dynamic stuff.
As said - I consider it just personal preference. There are
valid
reasons for both ways.
Micha -
I am looking for a solution to a problem I am having with an
XSL stylesheet and trying to use a php variable. The page I am
working on is a page to display some information based on the
graduation year of a class (I work at a school). For example last
years graduating class of 2006.
I have a statement in the XSL sheet that limits the shown
data to only that class year
<xsl:for-each
select="school[class_of='2006']">
I would like to replace that 2006 above with a php statment
such as $classyear since on that page the data is to display the
variable is already present, but I cannot get it to work. I have
tried to place php in the XSL and also to change the extention etc
and they all produce errors. I am assuming that XSL just can't use
variables in it?
Any help would be greatly appreciated. I would hate to have
to duplicate that one XSL sheet for every class year.
thanks
chrisDavid,
thank you so much so far for you help, it does sounds like we
are talking about the same thing. I think I am getting close.
I do want to pass the value when the XSL sheet is embedded.
I tried that and it seemed to not work, says the variable is
not found (I am using the dreamweaver built in transform).
I am just getting into the more complex XML stuff so I
apologize for my lack of knowledege.
I have pasted some of the code below, any idea what I am
doing wrong?
the page where it is embedded is
http://www.nmhschool.org/news/test11.php
php doc with the embed and include
<?php
$mm_xsl = new MM_XSLTransform();
$mm_xsl->setXML("test11.xml");
$mm_xsl->setXSL("test11.xsl");
$mm_xsl->addParameter("yearXX", "2006");
echo $mm_xsl->Transform();
?>
http://www.nmhschool.org/news/test11.xsl
is the XSL
<xsl:for-each
select="Report/GroupHeader2/GroupHeader2_1[q1.CnPrAl_Class_of =
$yearXX]">
<table width="100%" border="1" cellspacing="1"
cellpadding="1">
<tr> blah blah blah........
http://www.nmhschool.org/news/test11.xml
is the XML data -
Accessing PHP variables (especially _SESSION)
Hi,
since CaioToOn! suggested here that I should use $_SESSION and I need to do this anyway, I spent the last 1+ hours trying to figure out how to do that. Sadly, I could not really figure it out except that there seems to be an issue with the session ID and that it has to be passed along to the swf file.
Can somebody please tell me how to read/write from/to PHP variables (not $_GET)?
P.S.: Here a simple example code (test.php and then the testintro.fla AS code):
<? session_start();
$_SESSION["intro"] = 0; // has the intro been played?
... // code for including the swf
?>
if(intro == 0)
myclip.gotoAndPlay(2); // play intro
intro = 1;
else
{ myclip.gotoAndPlay(24); } // skip the intro and go straight to the endnone of those reasons would require php to embed a swf.
normally, with flash, you could use a session variable to pass data from html to the swf. you set your session variable's data with a html form or something similar and then use flashvars to pass that info to your embedded swf(s).
you can also pass html data to an embedded swf using javascript and the externalinterface class. -
Hello ,
Is it possible to change the property of an variable?
I used User Entry / Default value, But i need to change now to Customer exit.
But it does not allow me to change!
Is there any way to change?
Kind regards
Ram
Points will be assigned!hi
once defined u cannot change certain properties of variable.
some of this properties are
Technical name
Processing By (Replacement path, Sap exit etc.)
Reference Characteristics
Replace Variable with.
Variable Represents (Single, Multiple single, interval etc.)
it will be lot easier just to create a New variable.
if older variable represent wrong values or is created by mistake delete it. -
Change property server behavior
Page contains a list menu named "cities" whose label/value is
populated by rs_cities:
SELECT city_cit, provinceid_cit
FROM cities_cit
ORDER BY cityname_cit ASC
and contains a list menu named "province" whose label/value
is populated by rs_province:
SELECT provname_prov, provinceid_prov
FROM province_prov
ORDER BY provname_prov ASC
I would like to have the label of the list menu "province"
change to where cities_cit.provinceid_cit =
province_prov.provinceid_prov as a result of user selecting a city
from the list menu "cities"
Would this require the use of additional recordset that
contains a join or the need for altering existing recordsets?
How do I set the information in the "change property behavior
" dialogue box?Rick - I know that is possible (in theory) to trap the keystroke using JavaScript and replace it (or, do a focus() call or similar to move the focus to another element), but figuring out where you are in the table can get quite hairy.
To be honest, it's one of these things we've been meaning to implement on one of our apps (our issue is moving to the next element when the user presses ENTER), but haven't got round to yet.
I'd therefore be very interested to hear if you crack it (either using JS or some other method).
Cheers,
John. -
I have 50 different bool variables (indicator LEDs) & depending on
the situation I want to change the property of one of the variables.
Is there any way to select programmatically to select the which property of the variable I am going to change.
I dont want to make 50 different property nodes for each variable.
I want to have one property node and depending on the situation I want to assign that property node for one of the variables.
I have to do this because, I have to change the property of the LEDs in
so many times in the program in different postitions.
50 property nodes will make it hard to see the program.
Pls help in this matter.
NaushicaI have a similar (somewhat similar) issue.. I did read what tst proposed... many times over...
Here is the scenario.
I have many controls and indicators that I want to change properties from visible to invisible and back to visible.
They start by being invisible. Depending on operator selection some indicators / controls may become visible. And again, based on certain selections, they may become invisible (again) and others become visible. The controls & indicators are of different types, from boolean, text, numeric, image, etc...
The main vi, which was relatively clean now has become cluttered with approx 60 (seventy) property nodes which make the control / indicator visible / invisible.
There are other property nodes (approx 10) which modify values based on selections... We won't get into those at this time.
Is there a way other than clusters to reduce the number of property nodes to something like 5... (maybe 10). I do know about the references... What I'd like to accomplish is using an array of element names (ctrl / indicators) and feeding a loop which would set the appropriate attribute; especially since the property is chnaged in groups of elements at a time.
How to explain this.... so that it makes sense...
Take a look at the attached image. The simplest form of the question would be: "I want to have a single property node inside a loop which would make all seven (7) controls become invisible".
-- now I need a coffee --
JLV
Attachments:
property nodes.JPG 17 KB -
Assigning a javascript value to a JSP variable
How do i assign a javascript value to a JSP variable?
eg
<%
String JSPvar;
%>
<script language="JavaScript1.2">
<!--
var javascriptVar="hey"
-->
</script>
<%
JSPvar = javascriptVar ???
%>You do know that the JSP runs on the server and generates HTML, including Javascript, that is executed on the client, don't you?
-
How to change the font of variables in smart forms dynamicly
Dear all,
Is there any suggestion of how to change the font of variables in smart forms dynamicly?
Thanks in advance.Hi,
You cant change the font dynamically but tell me the scenario I will try to give the solution.
Regards,
Nageswar -
Dear Team,
Japanese characters alone are not passing correctly (passing like ??? or some unreadable characters) to Adobe application when we create input variable as XML data type. The same solution works fine if we change input variable data type to document type. Could you please do needful. Thank youHello,
most recent patches for IGS and kernel installed. Now it works.
Maybe you are looking for
-
Broken T-mobile 8220 flex cable (hinge) need help finding parts
Hey folks. Nice forum here ! My 8220 was working nicely until I broke the phone in half (I had anger issues I guess ! ) Anyways the the flex cable is broken now. THe hinge is fine as I snapped it back together and it operates normaly. The phone is
-
Hi Experts, I have requriment for ifile extraction . I have report which will extract the ifile for HSBC using code F110 which is used to generate automatic payment. I have requriment for part or full payments made before due date wi
-
Hey everyone, I'm trying to do a match/replace with a pattern that contains special characters, and running into syntax errors in a Flex 3 app. I just want the following regex to compile... (while also replacing html tags with "") value.replace(/</?\
-
Delivery Creation before a Scheduleline Date
Hi Gurus, I have a requirement to create a delivery before a scheduleline date, but system is not allowing to create a delivery and throwing a error message .Is there any user exit to create a delivery befoe a scheduleline date without hanging the da
-
Detail entity Location with row key null cannot find or invalidate its owni
I have a simple parent child relationship generated in ADF BC. It's 1 to many...a Work Request can have one or more Locations. If I turn on Composition Association in my assoc definition, I get "oracle.jbo.InvalidOwnerException: JBO-25030: Detail ent