HTML Code:
<script language=javascript>
id=Math.round(Math.random()*2)+1
document.write("<img src="+id+".jpg>")
</script>
above is the js code I use to generate a random id, which in effect displays id.jpg on the web page (assume we have id.jpg in the right folder).
When a user sees that page, he is going to choose what word describes the picture best. (purpose of CAPTCHA: verify the user is a human)
HTML Code:
<select name="selected[1]">
<option value="">Click to identify</option>
<option>Clock</option>
<option>Dog</option>
<option>Ship</option>
<option>Tree</option>
</select></td><td>
The selection is sent to backend php script using POST method.
Here is my problem: In the php script, I know, for example, the user chose Dog to describe the mysterious jpg generated by js code. But there's no way for me to know the id of the jpg file generated by js code. Hence, I will not be able to check whether the user chose a valid description of the jpg file.
How can I send information about the id of the jpg file to the php script?
Is it possible to make it so that when someone presses a certain key, or sequence of keys, on their keyboard a picture is posted instead of a letter? As in, if I type shift+c in a textarea or input box could an image be placed inside the textarea or input box instead of a "C"?
I am working on a web page where a random picture is displayed at each visit to the site. One requirement of the page is that it also works for users who have javascripts disabled.
I put a default picture in the page that get's swapped using an onLoad function. That works great for the javascript disabled browser because it just shows that default picture. However, when the page loads for users who do have javascripts enabled, they will see the default picture quickly change into the new random picture. It looks glitchy.
I've been trying to think of another approach where it will be seemless for either kind of viewer. Any ideas? Code:
I'm trying to make a Quiz that generates random pictures each time the page is launched , with multiple options for the user to choose the right answer satsifying the picture and its meaning .
I've made the pseducode and i understand the algorithm ..but i don't know how to write the statements .
My algorithm is :
1-Random picture is shown each time the page is launched.
2- 6 Buttons are placed .
3-user choses the right matching answer.
4- window is popped up saying "correct"when its correct if not , an alert saying ;'Your answer is incorrect. Please try again"
So this is the code i've made , i know there's errors but just to show the Idea.
The code is working 100%, but the only problem is with the function calling statement. It is working on the first img (picture) i want it to be called on the second picture.
<!DOCTYPE html PUBLIC "-w3cDTD xhtml 1.0 strict EN" <html xmlns=http:www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns = http:www.w3.org/1999/xhtml">
I've been working on photo gallery that can be seen here: [URL] I would like the title to change according to the picture selected. This works when you click on the thumbnail images. However, it current does not work with the drop-down menu, "back" and "next" buttons, or the automatic slide-show.
i looking for a way to stretch picture in background and put some divs over that picture with links and text. what i find so far don't work in all browsers any one know something like this?
Firebug's console is showing when visiting my test.html page Headers, Post and Response. In the Post tab it is showing: "id 9". I need to create a new page and get that 9 in it so I can use it. I don't mind jQuery, Ajax or Javascript but I need that 9. I know that with php I just need $_REQUEST["id"]; but I cannot use php.
I'm working on a form that I can add additional fields to dynamically (select fields and text input fields). I do so by clicking a button, which calls a javascript function, which in turn adds elements to the DOM. However, only the hardcoded (non-javascript created) fields are being POSTed. I assume this might have to do with the fact that the form uses tables to lay the fields out. The basic structure is similar to below:
I have a form which submits data to a php file, which than sends a pdf file containing the inputted data via php headers. So after the submit, you still see the page with the form on and get a pdf-download now I want to see if the pdf download-window came up and if so, redirect the user to another page (instead of the page where the form is on), but the window to download the pdf should be still there so the user is still able to download the file.
I am using ajax in my site and want to implement a friend request button. When a user clicks this button their userid and the userid of the friend thwey are requesting will go into a table called notifications in my mysql database. This works fine in regular html/php with javascript disabled but not when using javascript/ajax.
Here's my code which may clarify things:-
Code:
<script type="text/javascript"> function makeRequest(friendrequestloggedinuserid, friendrequestuserid) { if (window.XMLHttpRequest)
[Code]....
The above code works perfect if javascript is disabled and the button is clicked as the new row is inserted into the database however if javascript is enabled the alert shows inidicating the ajax file is working but the new row is not inserted. Is this something to do with the POST process between my javascript code and my ajax_processrequests.php file?
BTW $loggedinuserid and $userid are retrieved earlier on in my code but showing how they are retrieved is irrelevant to this because I know they are present at the point of the above code.
so just a simple questions maybe someone can help me out. I know nothing about java first of all but i do know in this code how to get rid of the comma - the only thing i need to change is to make it paste email results vertically instead of horizontally because it helps me collect emails from some older emails i have
How do I link a cookie, presented in a div, to a text box on the same page - so it can be searched?
Now I have a search box that link to the Google Maps API. I also have the two most recently search items to show up as cookies below the map. My goal is to have the cookies show up as links so that when you click them, they show up in the text box to search.
I'm thinking of three ways to do this and wonder which is the best way to do it.
1) Can I just adjust the div tag to link to the text box?
2) Can I adjust the function relating to how the cookies are posted on the page?
I have cleated a bit of code that will dynamicly add a new line to a form so the use can add an infinat number of entires for this element.The code adds the form elemetns in IE and FF ok but when i click the submit button it does not submit the information from the dynamicly added elements in FF.Oddly enough IE works fine!Here is the code:
I am new to jquery. I am trying to return a string array with two strings back to a jquery ajax call. On success, when I try to retrieve the values, my result is just a string "System.string[]". How do I retrieve the values that I returned from the server in my call back function for success.
I have a very large form and have a couple of checkbox groups where multiple items can be selected. They are grouped as an array of checkboxes. When I post the checkbox groups, the PHP script receives duplicate values. If the group has 2 checkboxes, 4 values are posted. If it has 10 checkboxes, 20 values will be posted.
i.e:
I then submit everything to a PHP script via an Ajax call, then output the result to a div. (see below)
However, when my PHP script loops over the $_POST array, it seems that each checkbox array is duplicated, so my PHP array returns:
This happens with all my checkbox arrays, but not with an array of hidden fields for some reason.
I don't think this is a PHP problem, as it looped over everything correctly when submitting via a conventional POST. I checked the contents of $_POST, and it seems that the duplicates are being posted.
I'm trying to use Javascript to have an array of images that load randomly AND work in a slideshow manner so change every 3 seconds (in a logical order). The code I have below presents a random image but how do I get them to continue from the random image and change to the next every 3 seconds?
I've looked for a solution to this issue, but it seems like a little different scenario than other situations. I made a system for generating friend requests on Facebook. I have a grid that is 6 x 3, for a total of 18 cells. Each cell has a picture in it, and the picture is linked to the Facebook friend request page. My problem is that since each cell is populated at random from the array, I'm getting lots of repeats. For example, some picutures are in 5 cells, and some are in none. I'm trying to figure out how to make it so that once a picture is used once in the grid, it does not get used again in the same grid.I still want every cell filled at random on each page load, I just want to prevent the repeating.
Here's my current code: <script type="text/javascript"> var vip_list=new Array( new Array('http://profile.ak.fbcdn.net/v225/1616/88/s1220771654_2158.jpg','http://www.facebook.com/addfriend.php?id=1220771654'), new Array('http://profile.ak.fbcdn.net/v223/1233/29/s904885342_9055.jpg','http://www.facebook.com/addfriend.php?id=904885342'),
For my website I would like to create a famous last words generator (randomized), and random page generator (within my site). What is the code for random quotes and random links?
I am new to javascript but have been using java for quite a while. I am looking to make a random quote (out of ten possible quotes) appear in my h2 tag in a page i am working on. In java, i would make a random number generator, in javascript it looks like this:
Code: var randomnumber=Math.floor(Math.random()*11) Then make an if statement: Code: if randomnumber=1 { var quote="Live long and prosper" }
document.write(var quote); Could someone more experienced than me tell me if my code looks good and how would a go about getting "var quote" in my h2 tag?
I am trying to dynamically clear the value of a form input field and then submit the form.When I used $('#my_field').val('') to clear the field, it was cleared on the screen but when the form was submitted the original value of the input field was posted.My browser is FireFox and I can see using FireBug that when the field is cleared, firebug is still showing the html code with the old value. E.G. <input type="text" value="old_value" />The same situation occurred if I used $('#my_field').attr('value', '') to clear the field.The same situation occurred if I actually changed the value of the field rather than just clearing it.To work around this problem I ended up using the $('#my_field').removeAttr('value') to clear the field before it was submitted.