HTML - Pass A Var To Javascript
I want to pass the value from 'event.clientX' of the html line: "alert(event.clientX)" to a javascript. Right there on the same page.
How can I do that? regards, ab good grief, hunting around I run across the fascinating information that 'alert' IS javascript ! Then how come this works: <html> <head> <title>Event</title> </head> <body onclick="alert(event.clientX + ' x ' + event.clientY)"> </body> </html> ? Javascript can be embedded in html and doesn't need that "<script language="javascript">" business? god almighty, what's going on............? Similar TutorialsI am wanting to create a booking form for my website, before you can make a booking you have to be able to check is available in your area. So I am wanting to be able use one form where you can enter all the required details and when you enter a postcode you click check, which will give a pop up box saying if someone is available or not. The problem I have found is if I use a link then the PHP code doesn't get any values from the form, if I use a submit button it does pass the value but the popup only comes up for a split second. Here is the code for the form as I said if I click the Check Button, it passes the value but only shows the pop up for a second, If you click "Find Driver" first it shows the Pop up but it is blank as It doesn't get the value from the form. If you click check and then Find driver it works fine, but I am wanting to find a solution by only using one click. HTML Code: <div id="form"> <form name="f1" method="post"/> <p> ID: <br/> <input name="ID" type="text" value="Leave Blank" /> </p> <p> Name: <br/> <input name="Name" type="text" /> </p> <p> Address: <br/> <input name="Address" type="text" /> </p> <p> Postcode:<br/> <input name="Postcode" id="Postcode" type="text" /> <input type='Submit' value='Check' onclick="popup('popUpDiv')" /> <p><a href="#" onclick="popup('popUpDiv')">Find Driver</a></p> </p> <p> Telephone: <br/> <input name="Telephone" type="text" /> </p> <p> Mobile: <br/> <input name="Mobile" type="text" /> </p> <p> AltTelephone: <br/> <input name="AltTelephone" type="text" /> </p> <p> Email: <br/> <input name="Email" type="text" /> </p> <p> Date: <br/> <input name="Date" type="text" /> </p> <p>Notes: <br/> <input name="Notes" type="text" /> </p> <p> CompanyNotes: <br/> <input name="CompanyNotes" type="text" /> </p> <p> Payment: <br/> <input name="Payment" type="text" value="Leave Blank for 0" /> </p> <p> <input type="submit" Value='Book' onclick="f1.action='insert.php'; return true " /> <!--<div id="wheel"><a href="instructorSearch.php"onClick="return popup(this, 'notes')"><img id="mainLogo" src="im/wheel.png" alt="Driving School Logo" /></a></div> !--> </p> <p><input type="submit" Value='Enquire' onclick="f1.action='insertEnquire.php'; return true " /> </form> Hi! I would like to know how do I pass a variable in my URL to the next page. HTML Code: For example, my URL is: http://www.mysite.com?source=google I'm using this form code to go to the next page: <form action="http://www.mysite.com/next-page.html" method="get" name="form"> <input type="text" name="zipcode" maxlength="5" id="zipcode" /> <br /> <input type="submit" id="button" value="Go"/> </form> So the next page URL will be: http://www.mysite.com/next-page.html?zipcode=11111 I want that the variable "google" will be also in this URL: http://www.mysite.com/next-page.html?zipcode=11111&source=google How I do that? Thanks, Steve Hi, I know how to make a username and password input form, and the submit button that is not the problem. My problem is that I have designed a background in PS.http://photoupload.org/uploads/13269813681.jpg And before anyone *****es at my for putting 'Shrimps' yes I know it is wrong. But this is for a gaming team I am in, and none of them are English. And they think that Shrimps sounds and looks better than Shrimp even though Shrimp is the correct plural. Anyway Back to the matter at hand. If you look at the background I designed, in the top left it has two boxes which is where I want to put the user and pass forms. But I don't want the boxes that naturaly come with the forms. And for the life of my I can't figure it out, I don't know weather it is HTML, XML or CSS, any help on how to get rid of the boxes that come with that would be highly appreciated, Thanks //Dave Hi created the following code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>validation</title> </head> <body> <ul> <li><a href="#">item1</a></li> <li><a href="#">item2</a></li> <ul> <li><a href="#">item2a</a></li> <li><a href="#">item2b</a></li> </ul> </ul> </body> </html> unfortunately it doesn't pass validation. Apparently, a "ul" elenent cannot be inserted into another "ul". So, how do i create a cascading menu? Thanks Hi all! I'm trying to pass an array as a hidden field from a form in the URL of the browser but it's not working. Can you tell me what is wrong with this...it's my first attempt so be gentle The form HTML is <form name="filter" action="http://www.myurl.com" method="get"> <input type="hidden" name="main_page" value="index" /> <input type="hidden" name="Flt_Grade[]" value="100" /> <select name="filter_id" onchange="this.form.submit()"> <option value="1">Most Popular</option> <option value="2" selected="selected">Price: Low to High</option> <option value="3">Price: High to Low</option> <option value="4">Title</option> <option value="6">Date Added: Newest</option> <option value="7">Date Added: Oldest</option> </select> </form> I would expect, when option 4 in the dropdown is selected the URL to be http://www.myurl.com&main_page=index...00&filter_id=4 Where %5B = [ and %5D = ] But what I actually get is http://www.myurl.com&main_page=index...e=&filter_id=4 The Flt_Grade array is not passed properly. Can this be done so the hidden field is passed in the URL as an array? Thank you! Hey everyone! So after ruling out more complex Java implementations of passing a string onto the end of a static link, I'm attempting to do the same using <form> and onclick but am having difficulties. What I am trying to do is simple. There will be a form box where the user enters their ZIP CODE and then clicks a button 'Go'. Once clicked, I'd like to open a separate window (or possibly leave everything in the same window-not important) where the 'zip code' string (ie: 12345) is attached to the end of a static link (ie www.website.com/zip= ) to direct the user to the link 'www.website.com/zip=12345' I realize this is a simple idea, but thus far tutorials have lost me. This is the code that I have, but I admit it is a mess and might just be a better idea to ignore it: Code: <form> <input type="text" maxlength="8" name="zip" style="color:#555555;" value="Your ZIP" class="cleardefault" onclick="http://www.t-mobile.com/coverage/pcc.aspx?zip="+zip"> <input type="button" value="Go!" onclick="http://www.t-mobile.com/coverage/pcc.aspx?zip="+zip" > </form> Again, I know this is very n00bish and annoying, but if you could help I'd greatly appreciate the time! Hi, I am trying to accurately code a swf header into my website. I don't have the knowledge to arrange the code so it passes html validation. The following link will take you to the site and validation results. http://validator.w3.org/check?uri=ht...sale.net.au%2F And here a link to the website http://www.bikesforsale.net.au Any help or guidance will be gratefully received Cheers Ron hiii all, i am making 2 html pages. one is parent window and another is child window but i want, when i click on a link of child window , parent page will load but with diff frame on parent page i am able to reload the parent pag but the same form will appear so how can i load diff form when parent page is reload?? please mention code for both child and parent page and i am using html e\with java script please reply thanks My html problem keeps failling, with all my image codes.. shown for 10 errors which are all for the images what's wrong? Here is the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- New Perspectives on HTML and XHTML 5th Edition Tutorial 2 Case 2 Fiddler Home Page Author: Date: 2-16-2011 Filename: home.htm Supporting files: fiddler.jpg --> <title>, ITSE 1411 Lab Project 2, Tutorial 2 Case 2, Due 02/23/2011</title> </head> <body> <div> <img src="fiddler.jpg" alt="Fiddler on the Roof" /> <hr /> <a href="home2.htm"><img src="home.jpg" alt="home" /></a> <a href="slide1txt.htm"<img src="start.jpg" alt="start" /></a> <a href="slide1txt.htm"<img src="back.jpg" alt="back" /></a> <a href="slide2txt.htm"<img src="forward.jpg" alt="forward" /></a> <a href="slide6txt.htm"<img src="end.jpg" alt="end" /></a> <br /> <a href="slide1txt.htm"<img src="thumb1.jpg" alt="slide1" style="border-width: 5" /></a> <a href="slide2txt.htm"<img src="thumb2.jpg" alt="slide2" style="border-width: 0" /></a> <a href="slide3txt.htm"<img src="thumb3.jpg" alt="slide3" style="border-width: 0" /></a> <a href="slide4txt.htm"<img src="thumb4.jpg" alt="slide4" style="border-width: 0" /></a> <a href="slide5txt.htm"<img src="thumb5.jpg" alt="slide5" style="border-width: 0" /></a> <a href="slide6txt.htm"<img src="thumb6.jpg" alt="slide6" style="border-width: 0" /></a> </div> <hr /> <div> <img src="slide1.jpg" alt="slide1" /> </div> <blockquote> <p><i>Do You Love Me?</i> sung by Deb Ingalls and Thomas Gates</p> </blockquote> </body> </html> HI everyone, I am in process of creating a sample page. I need to pass values from one HTML page and i should get those values in other page. For example i have used two sample pages like, sample.html l<html> <head> <title> My first page </title> </head> <body> <a href="sample1.html" id="1001">Welcome to html </a> </body> </html> sample1.html <html> <head> <title> My second page </title> </head> <body> <a href="sample1.html">Sample HTML page values came here</a></body> </html> I have used those two sample pages and i need to get the value of id="1001" in sample 1.html page could anyone help me to solve this problem. Thanks in advance Regards, Martin OK so I'm making an application and I've hit a snag with my Javascript. So I have a form and a list with some value, and under the list I have a button (not a submit) HTML Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript"> <!-- function popUp(URL,WIDTH,HEIGHT){ day = new Date(); id = day.getTime(); var user = document.getElementById('user').value; eval("page" + id + " = window.open(URL, '"+ id + "', 'toolbar=1,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+WIDTH+",height="+HEIGHT+",left = 362,top = 234');"); } </script> <style type="text/css"> form{ margin: 0px; } .menu{ width: 200px; } #mem_list{ width: 200px; } </style> </head> <body> <div id="mem_list"> <center> Online User Info </center> <form method="get" action="/antrix/index.php"> <select name="color" size="5" class="menu" id="user"> <option value="Marlo">Marlo level 70 Warrior</option> <option value="Dsadasd">Dsadasd level 1 Warlock</option> <option value="Dsadasdd">Dsadasdd level 1 Priest</option> <option value="Asdassg">Asdassg level 1 Rogue</option> </select> <center> <input type="button" value="user options" onclick="javascript:popUp('mailmod.php','800','200')"/> </center> </form> </div> </body> </html> OK so when someone clicks the user options button i want the popup to go to the url and have the selected name in the GET value of the url like: mailmod.php?user=marlo if Marlo was selected. anyone got any ideas? *EDIT* yeh just realised this was in the wrong section, sorry ^_^ Hope this is the correct place for this question. What I want to do is have a webpage which asks a question, e.g. "What is your name?" and when the user enters a name, e.g. "Bob" a button pops up with "are you ready?" The user clicks that button and the page then tells the visitor: "Good morning, Bob; nice to see you" (or the button could be there from the beginning; it does not have to pop up) Just want this to learn how to do this and hope I can carry on from there. I am assuming I need a javascript to do this. For the website I'm working on i want to store the text someone enters in an imput box to be stored as a variable so i can have an alert that welcomes them to my site. any suggestions. this one isn't illegal. I am currently working on a currency converter for my D&D website and have run into a bit of a problem. The basic idea is to select the appropriate currency you have from a row of radio buttons, insert the amount you have in a text area and in the next text area it will kick out a list of different currencies and the amount you will have in those currencies. My problem is that my JAVA skills are extremely poor. I figured out how to set up most of it but I cannot figure out how to grab the input and plug it into my formulas. Can anyone help me with this? Here is a link to the page: Currency Converter Any and all hope is greatly appreciated. Thanks. Take care and have a great day.... ciao, john., Here is the basic code without the web page info: Code: <script type = "text/javascript"> function radio_map(prefix) { var coins; // The type of coin selected // Go through all options to find the one that was selected for (cnt = 0; cnt < prefix.cointype.length; cnt++) { // If the coin was selected, checked will be true if (prefix.cointype[cnt].checked) coins = cnt; // Save that coin number } switch (coins) { // Copper case 0: prefix.matharea.value = "\n" + 1 * 1 + " Copper Coins \n" + 1 * .1 + " Silver Coins \n" + 1 * .01 + " Gold Coins \n" + 1 * .005 + " Platinum Coins \n" + 1 * .0001 + " Mithril Coins \n"; break; // Silver case 1: prefix.matharea.value = "\n" + 1 * 10 + " Copper Coins \n" + 1 * 1 + " Silver Coins \n" + 1 * .1 + " Gold Coins \n" + 1 * .05 + " Platinum Coins \n" + 1 * .001 + " Mithril Coins \n"; break; // Gold case 2: prefix.matharea.value = "\n" + 1 * 100 + " Copper Coins \n" + 1 * 10 + " Silver Coins \n" + 1 * 1 + " Gold Coins \n" + 1 * .5 + " Platinum Coins \n" + 1 * .01 + " Mithril Coins \n"; break; // Platinum case 3: prefix.matharea.value = "\n" + 1 * 1000 + " Copper Coins \n" + 1 * 10 + " Silver Coins \n" + 1 * 5 + " Gold Coins \n" + 1 * 1 + " Platinum Coins \n" + 1 * .1 + " Mithril Coins \n"; break; // Mithil case 4: prefix.matharea.value = "\n" + 1 * 10000 + " Copper Coins \n" + 1 * 1000 + " Silver Coins \n" + 1 * 100 + " Gold Coins \n" + 1 * 5 + " Platinum Coins \n" + 1 * 1 + " Mithril Coins \n"; break; } } </script> <form name="frmRadio"> <p> Please choose your coin type.</p> <div onclick ='radio_map(document.frmRadio)'> <input type="radio" name="cointype" value="Evanston"> Copper <input type="radio" name="cointype" value="Arlington Hts."> Silver <input type="radio" name="cointype" value="Oakbrook"> Gold <input type="radio" name="cointype" value="Downers Grove"> Platinum <input type="radio" name="cointype" value="Vernon Hills"> Mithril </div> Please input the number of coins that you have: <textarea name="coinarea" rows=1 cols=35> </textarea> Here are your converted coin numbers: <textarea name="matharea" rows=10 cols=35> </textarea> </form> Hello everyone, newbie to this forum humbly seeking help. I'll got a javascript working to display an alt image on hover and at the same time an image box appearing at another place on the page (describing the link). After preparing the linked page I discovered that the link doesn't work. When I add "a href" within the code which already only has a "href" in the javascript the complex image cutting becomes apparent with a pixel or so space between each of the cuts. I had alt images working nicely, now I find something is very much a miss. Here is the code which delivers the two alt images well but doesn't link to the target page. "<tr><td><div id="NavigationImage3" href="about_us.html" onMouseOver="F_roll('NavigationImage3',1)" onMouseOut="F_roll('NavigationImage3',0)"><img id="NavigationImage3" name="NavigationImage3" src="images/b2-3a.jpg" onLoad="F_loadRollover(this,'images/b2-3b.jpg')" alt="Sample Text" onMouseOver="swap(3, 'imgDefault')" onMouseOut="swap(0,'imgDefault')"></a></td></tr>" Be very grateful if someone can help. Cheers, Mal from Cessnock (Aus) So I want to make an image that has mouseover tables that pop up. This is what the code looks like now: Code: <html> <table> <tr><td><img src= "pic.bmp" usemap="#mapareas"/></td></tr> </table> <map NAME ='mapareas'> <script language='JavaScript' type='text/javascript'> function show(id) { document.getElementById(id).style.visibility='visible'; return true; } function hide(id) { document.getElementById(id).style.visibility='hidden'; return true; } </script> <area shape = "rect" coords="0,0,100,100" title="one" onmouseover='javascript:show('one') onmouseout='javascript:hide('one')> <area shape = "rect" coords= "150,0,250,100" title="two" onmouseover='javascript:show('two') onmouseout='javascript:hide('two')> <area shape = "rect" coords= "0,150,100,250" title="three" onmouseover='javascript:show('three') onmouseout='javascript:hide('three')> <area shape = "rect" coords= "150,150,250,250" title="four" onmouseover='javascript:show('four') onmouseout='javascript:hide('four')> <area shape = "default" title="The Rest"> </map> <table border=0 cellPadding=0 cellSpacing=1 id='one' style='position:absolute; left:10px; top:120px; background:lightGrey; visibility:hidden'> <tr><td>ONE</td></tr> </table> <table border=0 cellPadding=0 cellSpacing=1 id='two' style='position:absolute; left:10px; top:120px; background:lightGrey; visibility:hidden'> <tr><td>TWO</td></tr> </table> <table border=0 cellPadding=0 cellSpacing=1 id='three' style='position:absolute; left:10px; top:120px; background:lightGrey; visibility:hidden'> <tr><td>THREE</td></tr> </table> <table border=0 cellPadding=0 cellSpacing=1 id='four' style='position:absolute; left:10px; top:120px; background:lightGrey; visibility:hidden'> <tr><td>FOUR</td></tr> </table> </html> everything is ok when the page is first loaded, but when I try the mouseovers, firefox's error console gives me this message: "syntax error javascript:show(" and "syntax error javascript:hide(" Can someone help me figure out what is going wrong? Thanks |