Set Php "$variable" By Java "onclick"?
Jun 7, 2009Is it possible to set php "$variable" by java "onclick", for example: <a href='test' onclick='<?php $variable = 10; ?>'>?
View 2 RepliesIs it possible to set php "$variable" by java "onclick", for example: <a href='test' onclick='<?php $variable = 10; ?>'>?
View 2 RepliesI have a table on a html page, on some of the <td>'s are onclick evens ... for example ...
onclick="add();"
Later on that page is a div which is hidden when the page loads, I have the following javascript that sets its visibility to visible, showing the DIV, as per below.
function add() {
MMDiv2.style.visibility='visible'
}
What I wish to do now is to send a value on the onclick. I have 1 DIV that gets displayed and hidden and several <TD> onclicks that do it. Is there some way to send a variable from the onclick of a <TD> to the div. For example, in the DIV will be a text form field, is there anyway to populate this with a value from the onclick to tell which <TD> has been clicked?
i'm not really sure how to explain this, since I know nothing about javascript, so i'll try and illustrate by the use of php (hope it makes sence)
I have a set of different links, like:
<a href="link.com?page=text1">text 1</a>
<a href="link.com?page=text2">text 2</a>
<a href="link.com?page=text3">text 3</a>
etc, where page is dynamic and can be anything I chose..
Another place in the same document, I echo out what the page variable is, like:
echo "$page";
so when clicking "text 1" the echo will output what i've defined the page to be, in this case "text1" ..
So I want to be able to click the links and change the output of the echo all depending on what i've defined in the link - without refreshing the page!
Is there any easy way to do this?
I am trying to apply the current value of variable i to the links onclick event
I've even tried assigning it to variable j but the only values I get when any link is clicked is
i = 5
j = 4
The "page"+i and "Link"+i show as they should with variable i showing the correct value. Code:
I have a JS variable I want to write inside of a onclick="" attribute. Example:
<script>
var cool = "hello";
</script>
<a href="#" onclick="RunFunction(cool)">Text</a>
I know how to pass a variable to a url using href.
(href="thisurl.php?thisvar=thisvalue")
now I want to do this using onClick, how do I?
Basically, I have a form with some text fields, and I want to put a button next to each text field, so that when a user clicks on the button, it increments the value in the field by 1. I know how to do it if I know the id of the text field, but what if the id of the text field is a variable? How do I do it? Here's my code:
<script language=javascript>
function process(v){
document.getElementById('order_item' + v + '_quantity').value++;
[code]....
My issue is with my onclick statement:
<input type="button" value="Add +" onclick="javascript:process(0)">
This works fine for my first field, but I need to have one for every text field, so how do I pass my counter variable (which determines the id of the appropriate text field) to the process function?
I have a book on my page consist of 3 iframes, 1 iframe opens the table of contents and 2 iframes to open 2 pages at the same time, also i have 2 buttons to navigate pages next and previous through this function
[Code]...
the problem starts here, if i click on next-previous button I want it to continue from page 36,37 but what happens it continue from pNum in the function, how to update the pNum from onclick ?
I am building a site where I want all links to partial page reload using xmlhttprequest and innerhtml. I have done this before, butI always had to have a seperate xmlhttprequest function for each link. So this time I am trying to write just one function, and have the onClick change which document the request is getting. It is not working and I appear to novice to figure out why. Here is the code, i have bolded some relevant lines:
<script type="text/javascript">
function ChangeContent()
{
var whichPHP;
[Code]....
Also, if I use the innerhtml function to write another of these hrefs, will that link be able to access the function if it is in the header, or should I put the entire function in a .js file on the server? The point of all this would be that the entire page never reloads and all the text content is swapped out on demand.
I am trying to use an onclick statement to go to an alternate web page displaying a different version of tha file being displayed in the current page.
In the HEAD section of the current page I have a global variable named currentfile that contains a file name. This function is also in the HEAD section immediately below the variable's declaration
I have tried every combination I can think of in the onclick code to get it to work but, no joy. here is an example:
I just can't get the next page to load.
I am trying to access a dynamic asp variable with onclick either in a javascript function where I can use it globally or set another div id with this dynamic variable.
<script>
function doSomething(article_id)
}
[code]....
I have a form, that when the user click Submit, I need a php variable to be echoed to the page. This is for an upload page. So when they are waiting for the file to upload, it will say "Uploading..." until the upload is complete.
All I know so far is I need to create a javascript function and include it in the submit button. This is all I have so far in the submit button tag:
onClick="Transferring();"
I'm trying to make a basic rss reader with a google reader-esque functionality of clicking on article names and being able to expand/collapse that article. I'm working on the expand part and am going crazy. I am having no trouble getting content and displaying it without the onclick function but when I try to integrate onclick I can just get the titles.
[Code]...
I have this web application where users are able to fill out and submit reports. The reports and scripts are part of a whole system, that is, they are used on a couple of different clients written in both vb and c#. This is the web-version of those clients.The scripting language is javascript and is executed using different script engines on the different systems. But for the web-version it is just executed in the browser.The different fields in the report can be accessed by typing:ID1.value. To get ID1 to apply for the input-field with id ID1 I had to in the initfunction of the page write a window["ID1"] = document.getElementById("ID1");
But my problem is when this element change. Cause in the report I have a special element that in the browser is translated to a table-element with a report-field in each cell.When I switch the current row, I need to update the window["ID1"] to equal the correct report field on the selected row. But when trying to access the new variable ID1 from a buttons onclick event it is undefined.<input type="text" id="test" onclick="alert(ID1.value);" />What I think happens is that when the page is first drawn the onclick event is created and as I understand, variables inside an event has the same value as when the event was created.
So if ID1.value was something when the page was created it will be the same when it is called even if the value of ID1 is different. And that seems to be the case. When I debug the page, before entering the event, ID1.value has the correct value while inside the event it is undefined and after the event it has the correct value. If I write window["ID1"] correct value is also shown.But a weird thing is that in another place in the code I had the same problem but instead of having the code inside the onclick event I first had a global function changeActiveRow and inside that I had an eval, eval(document.getElementById("ID1_script")) where ID1_script is a hidden element whos value is a script using ID1.value and that works.
Simply put, I need to take a variable (The number '20' in this case) that is displayed by an input box on my web page and plug it into a function so that whenever I click on a button, the number in the input box will decrease by 1.
Seems simple enough, though for hours I've been going at it with no luck. Skipping the rest of my code - I currently have:
<head>
<title> Online Slots </title>
<script type="text/javascript"
src="http://dave-reed.com/book/random.js">
[Code].....
The entire code is a slot machine project that's supposed to be extremely simple where you hit the button and it spins 3 wheels, 3 of the same image and you win. Every spin takes $1, every win gives $13.
The majority of the code is already working, however for some reason I appear to be failing badly at getting the read out to show a decrement of $1 every time you push the button.
I've tried so many different ideas that I've found across w3schools, webdevelopersnotes, dave-reed, ect - and so far I haven't been able to get any of them to work correctly.
I'm trying to create a short, html/javascript mario text game. Now, in the beginning, he fights a goomba.
He has a health and energy number as variables:
And then, there will be different buttons for different attacks. However, the only one created is "Punch", with this code:
What would I put in the onClick function to make it subtract 4 health from the goomba and 2 health from Mario.
Below is the code that is using the name FFF in various places. The effect of all this is that the onclick function is not executed. I would expect a pop up alert when clicking the submit button. This only happens if I rename either the form id or the js variable. Can anyone explain what is going on here ?
[Code]...
I'm more of an actionscript person but got roped into an html/javascript job.What I need to do, and it shouldn't be that difficult is this:page1.html - there is a yellow button and a red button - if the user clicks on the yellow button I want to set a cookie with the value "yel" then load the next page - if they click the red button set that cookie with the value "red"page2.html - 'onload' i want to read that cookie and load up the main image to match, something like this maybe?... document.mainimage.src='img/main_' + variable + '.png'so that the path would be for example 'img/main_red.png'f you think this would be easier sending that variable in the URL instead of as a cookie please explain. I'm having a very hard time searching for tutorials that are any good and that do exactly this kind of thing.
View 4 Replies View Relatedwhat i want to do-
$
(
"#temp"
).
[Code]....
I have a html page with a lot of thumbnails. The idea is that when the user clicks on an image the onClick event is to display another detailed form and deliver to that form the name of the image in a variable. In the detailed php-form there is a query to MySQL to retrieve a record. The record will be retrieved by a Query based on the name of the picture. Apparently the PHP cannot do the job. I had an idea to make the thumbnail page as a form and to use use a hidden field with the thummnail name which should be carried on with the $_POST array through the submit button but i do not want to have a submit button. The more elegant way is just by clicking the picture the detailed page is opened and the variable is transferred where my php code can make use of the variable for the query. I have never used java before so you have to excuse for the lack of knowledge.
View 3 Replies View RelatedHey all, I'm using a fairly simple accordion script. When I went to take a gander at the page in IE I found that the onclick function of the script doesn't respond. It works in FF, Safari, Chrome and Compatibility Mode in IE 8
the error message IE gives me is
Message: 'h' is null or not an object
Line: 13
Char: 77
Code: 0
URI: http://proposalfor.us/js/script.js
The problem line (as far as I can tell) is:
this.a[s]={}; this.a[s].h=h=T$$(e,v)[0]; this.a[s].c=c=T$$('div',v)[0]; h.onclick=new Function(this.n+'.pr(0,'+s+')');
I have a bunch of .js files that I insert into my my html file using
the <script> tag, and this works just fine. The .js files contain
info about the menu, table set up, etc. and take care of the page
format.
But now, I have a tidbit of Javascript in an htm file, and this tidbit
opens up a new window with some information on it. I want to insert
all of the menu and format javascript files on this new window that it
opens. so, my question is: how would I do this: (since this doesn't work!)
output.document.write('<SCRIPT language=JavaScript
src="/scripts/menu_array.js" type=text/javascript></SCRIPT>');
Anyone know a good site that'll teach you how to make a drop-down navigation
bar? I assume it is javascript
I have a drop down field that is dynamically populated using an XML sheet that looks like:
Code:
I populate the dropdown box using javascript that looks like this:
Code:
My the drop down form looks like this:
Code:
When a user clicks on the drop down box, all of the values inside "<title>" tags get displayed. Once the user has made their selection, the form is submitted and posts the user's option. My problem is that when the user clicks on the drop down box, I want them to see the content included in the "<title>" text but I want the form to post the data included in the "<xml>" tags.
For example, if the user clicks on the drop down menu and selects the option 'Animals' I want the form to post 'xml/animals.xml'. Any ideas how to handle this?
i have found using java script as an exam timer for displaying it to the client is more good than using php..
but i want the page to exit as soon as 40 misn are out...
if java says 40 misn out is there any way for the php to
note that and perform the rquired action?
i am thinking of parallely starting a timer at the server side in php
do u think so? or is htere any way for java script to tlel php the times out
I have been creating a webpage and I have added some buttons via frontpage and linked them to another page, the thing I cant figure out is how to add commands like a javascript button to enable a smaller window, no toolbars, no scroll bars etc.
is there any way i can make the buttons so when they are pressed a window opens with my dimensions etc?