JavaScript - Text In Form Goes Away On Click
hey guys
i dont know if this is javascript or not but i need text in a message body form to instruct people what to write about and then i need it to dissappear once the user clicks into it heres the link, http://www.blusmash.com/test The "Message" text box need to have stuff in it thanks! Similar TutorialsI'm trying to figure out how to both make the text grey and when a user clicks inside a input field remove the helptext. So far I got this: Code: <input onfocus="this.select()" onblur="this.value=!this.value?'E-mail here':this.value;" name="name" value="E-mail here" type="text"> What this does is allmost correct, but it doesnt remove the predefined text "E-mail here", it just select it all, and then the text is not grey... Can somebody please guide me in the right direction... Thanks in advance! Hi I have created the following effects on the images seen here http://techavid.com/design/test3.html . You see when you hover and then click on each image, they go from grey to color. When you click on one - the others go grey and the one clicked remains color. That's cool, but now I need the text 1st: Sun for example to display and hide along with its graphic button. The word "Sun," is a link that needs to link out to a URL so it has to be separated from the image effect code. Here code I have now.... Code: <style type="text/css" media="screen"> #wrapper { background: url('_assets/images/sun-inactive.p') no-repeat #777eee; width: 470px; margin: 0 auto; } a#sun{ background: url('_assets/images/sun-inactive.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; float: left; } a#sun:hover, a#sun.active { background: url('_assets/images/sun.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; } a#plane { background: url('_assets/images/plane-inactive.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; float: left; } a#plane:hover, a#plane.active { background: url('_assets/images/plane.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; } a#nano { background: url('_assets/images/nano-inactive.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; float: left; } a#nano:hover, a#nano.active { background: url('_assets/images/nano.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; } #popuptext { float: left; margin: -30px 0 0 0; padding: 0 0 0 0px; font-size: 11px; } #popuptext a { color: #ff6600; padding: 0 30px; } </style> </head> <body> <div id="wrapper"> <div id="navigation"> <a id="sun" href="#"></a> <a id="plane" href="#"></a> <a id="nano" href="#"></a> </div> <div style="clear:both"></div> <div id="popuptext">1st: <a href="#">Sun</a> 2nd: <a href="#">Airplane</a> 3rd: <a href="#">Nano</a> </div> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8"> $(document).ready(function() { // target each link in the navigation div $('#navigation a').click(function() { // link that you clicked clicked = $(this).attr('id'); // make sure that all the others are not active // except for the clicked one $('#navigation a').each(function() { if ($(this).attr('id') == clicked) { $(this).addClass('active'); } else { $(this).removeClass('active'); } }); // prevent the default link action return false; }); }); </script> What jquery or javascript code do I need to do this? thanks, chaser Hi im using this to hide and show some text, how do i do to change the text "Show" to hide when i click it and back to "Show" when click it again. Code: <script type="text/javascript"> $(document).ready(function(){ $('.accordion-content').hide(); //toggle the componenet with class accordion $('.accordion-toggle').click(function(){ //$(this).toggleClass('toggle-accordion-active'); $(this).next('.accordion-content').slideToggle(300); }); $('#accordion-expand-all').click(function(){ $('.accordion-content').slideToggle(300); }); }); </script> Code: <p><a id="accordion-expand-all" href="#">Show</a></p> Hello guys, I'm new to Javascript and my question involves text appearing upon a button click or after a set time. I have the following code: Code: <script type="text/javascript"> function timedMsg() { document.write("Timed Messege."); } And the button: Code: <form> <input type="button" value="Display timed alertbox!" onClick="timedMsg()" /> </form>[ I guess document.write is not the correct command to use in such situations, since it just replaces the whole page. Which command should I use so that the wanted text appears within the page, without reloading or replacing it? Thanks in advance. I could not find a proper command in my search. I wish to have my form update a text field when a 'add' link or button is clicked, allow for more entries to be added without having the page refresh. but i need to be able to have both the friends name and their number added to the field like so if friends name is say 'jason' and their number is '0987654321' then it will add to the textarea like so. jason [0987654321] this way i should be able to get the data and split it up when the form is send so i can add them in the DB. the part i am stuck on is how to get both fields in the textarea. allowing for more to be added without a refresh. can anyone suggest how they might do this. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form name="AddUser" action="" method="post"> <div> <div class="formspacer">Username: <input type="text" name="username" id="username" value=""></div> <div class="formspacer">Contact Telephone Number: <input type="text" name="phone" id="phone" value=""></div> <div class="formspacer">Your Email address: <input type="text" name="email" id="email" value=""></div> <br /> <div class="formspacer"><strong>Enter each entry and click ADD to insert.</strong></div> <div class="formspacer">Friend name: <input type="text" name="friendname" id="friendname" value="" size="40"></div> <div class="formspacer">Friend`s mobile: <input type="text" name="friendmob" id="friendmob" value="" size="20"> <br />ADD<br /> <textarea disabled name="MULTIfriend" id="MULTIfriend" cols=20 rows=10></textarea></div> </div> <input type="submit" name="AddUser" value="Add User"> </form> </body> </html> Hi there! I need help! Basically, I need to create a sentence and on one of the words the person accessing the site can click the word and it will change to another word and then again to a third word and so on for 5 words then it will, on click, return to the 1st word again. like a circle of various words. I've managed to get it to work with 2 words back and forth - but I need it to have multiple states. I need the JS and how to impliment it in the HTML. JS isnt my strong point just yet Please help me! Thanks so so much! follow me on twitter - @robyn_90 Ok. I'm going to start by saying I'm a complete novice. I am having a hell of time finding specific codes for the things I need. I'm pretty impressive I've gotten this far. So I am trying to make a portfolio website, for myself, which has thumbnails on the left(which I'll crop in photoshop because it is easier for me than having to do any coding) which will make the main image on the right change. At the same time, I want it to change the text below to correspond to the current image. Now I have the images swapping alright, except that the thumbnails that have the onClick function in them won't sit inside the table I have inside the table. I don't understand why that happens. I can work around this, and just get rid of that table. Another problem is that even though I defined the collumns as each being 20%, they are not all the same size. I am using percentages so that the site will function regardless of screen resolution. Anyway, here is my current code. Ignore the image names, I'm just using what random images I have at hand while I test things out. Code: <html> <head> <script type="text/javascript"> function swap(image) { document.getElementById("main").src = image.href; } </script> </head> <body> <table width="80%" align="center"> <tr><td colspan="5">I'll put a header image here.</td> </tr> <tr> <td width="20%"><center>Print</center></td> <td width="20%"><center>Motion</center></td> <td width="20%"><center>Photo</center></td> <td width="20%"><center>Misc</center></td> <td width="20%"><center>Resume</center></td> </tr> <tr> <td colspan="2"><table align="left"> <td colspan="100%">Catagory 1 </td> <tr> <a href="mario.jpg" onClick="swap(this); return false;"><img src="../Jpg/sluticon.jpg"></a> <a href="../Jpg/cattits.jpg" onClick="swap(this); return false;"><img src="../Jpg/sluticon.jpg"></a> <a href="bowie.jpg" onClick="swap(this); return false;"><img src="../Jpg/sluticon.jpg"></a> </tr> <td colspan="100%">Catagory 2 </td> <tr> <td><img src="../Jpg/sluticon.jpg" /></td> <td><img src="../Jpg/sluticon.jpg" /></td> </tr> </table></td> <td colspan="3"> <img id="main" src="bowie.jpg" width="400"> </td> </tr><td colspan="5"> <p>Description goes here</p></td> <tr> </tr> </table> </body> </html> I have a small snippet of code which will copy the contents of a textbox to the clipboard when a small image, say a button, is clicked. I want to achieve a similar effect when I click a hotspot on an image, but in this case the text will have to come from...well, I don't know. Maybe the title in an area tag? This is what I have so far for a textbox: Code: //clipboard copy function ClipBoard(what){ Copied = document.getElementById(what).createTextRange(); Copied.execCommand("Copy"); alert ("Information copied to the clipboard. Use CTRL-V to paste."); } <textarea id="holdtext1"></textarea> <img border="0" src="copyclick.gif" onclick="ClipBoard('holdtext1');" alt=" Click to copy text to clipboard / CTRL-V to paste" style="cursor: hand" width="18" height="18"> Does anyone have any ideas? Hi, I am trying to implement something like a javascript that can click and focus the Status Update Box on Facebook. Till now, I have nothing in hand that can perform the task so I thought about a javascript that can do it. I am not even a newbie to javascript but I know that it can perform various complicated tasks on client side. Can anyone here tell me how do I click the Status Update box and set it to focused by a javascript so that when I start typing the Status box receive the text ? Thanks Hello How to Make a Html Form Shows Up when Visitor Click a Link .. I have seen Site where you want to add Message u click Link then the Form under the Link Shows Up .. it stays Hidden unless Visitor Click Link 'Send Message' . It seems done by Java but How .. I am looking for a javascript code for this idea under this message ---------------------------------------------------------------------------------------------------------------------------------------------------- I want to create a kind of shopping website so when you click on a image or text it will add some text to a textarea,, it will include the name of item and price of an item i am new to sencha touch,and i created a login form which accepts user id and password and a login button,so when i click on login button i should get the user id value as a alert.and the code is Code: Ext.setup ({ onReady: function () { var myform=new Ext.form.FormPanel({ id:'form', fullscreen:true, standardSubmit:true, dockedItems:[{ Dock:'top', xtype:'toolbar', height:40, title:'Tool Bar', id:'login', } ], items:[{ xtype:'textfield', name:'id', width:'50%', align:'center', label:'User Id' }, { xtype:'textfield', name:'pwd', id:'pwd', width:'50%', align:'center', label:'Password' }, { xtype:'button', ui:'round', width:'50%', text:'Login', align:'center', handler:function() { gettingvalues();/* var fields = form.getValues(); console.log(fields['name']); */ } } ], }); gettingvalues=function() { var fields=myform.getValues(); Ext.Msg.alert(fields['id'].getValue()); } } }); But am not getting any value in alert,what i have to do. and after that i want to send those values to our local server which requires id and password,it will be in the format of... oururl?action=login&id=xyz&pwd=xyz, in this it will accepts and returns the response,so for that what i have to write, please let me know as soon as possible. Thanks in advance. Hi, I have a form that when you click submit gives a warning box asking if to continue code below Now when I type in the text field and press enter it doesn't submit nor does it pop up the warning box, how would I do this Code for submit button Code: <script LANGUAGE="JavaScript"> <!-- function submitMyForm() { var agree=confirm("ARE YOU SURE ?"); if (agree) return true ; else return false ; } // --> </script> Code: <form action="admin-delete.php" method="post" name="cp_delete" id="cp_delete"> <input type="text" name="cp_delete_bg" id="cp_delete_bg"> <input type="submit" name="submit" value="submit" onclick="return submitMyForm()"/> </form> I have a form with two text input boxes. I want to limit the text typed into the boxes as follows: 1. Either box can have the number 2 typed in, but the other box must remain empty OR 2. Each box can have the number 1 typed into Is this possible with JS and, if so, how do I do it?? Hello, I have 2 things I'm trying to figure out. 1. First form on the page has questions with radio buttons. Each radio's value is a number so a score is assessed at the end. 2. Second form on the page is an email the admin form, which duplicates the score in one field. Question: I would like to know how to write the form results to a text area in second form. However, I can't do this for one, and secondly, the value is a number, can I use labels? Here's the code I've 'made up' so far... JS (i know it's wrong) Code: <script LANGUAGE="JavaScript" type="text/javascript"> function display() { message = "<ul><li><b>Question 1: </b>" + document.quizform.Q1.label; message = "<li><b>Question 2: </b>" + document.quizform.Q2.label; message = "<li><b>Question 3: </b>" + document.quizform.Q3.label; message = "<li><b>Question 4: </b>" + document.quizform.Q4.label; message = "<li><b>Question 5: </b>" + document.quizform.Q5.label; message = "<li><b>Question 6: </b>" + document.quizform.Q6.label + "</ul>"; document.write(message); } </script> Form field example: Code: Question 1:<BR> <label for="Yes"><input type="radio" name="Q1" value="0" checked></label>Yes<br> <label for="No"><input type="radio" name="Q1" value="10"></label>No<br> <label for="I don't know"><input type="radio" name="Q1" value="10"></label>I don't know<br> Ok know those people who are in the bad habit of double clicking everything? Well my site breaks if they double click it... is there a script I can use that won't let my functions run more then once every so many seconds? to avoid double clicking errors? well title says it all i have a search form, and the default value is "enter text here" when the user click the submit button, i would like to check if the value of my text input is "enter text here" and if it is, then don't submit the form (popup a warning or something) how can i do that? thanks a lot! Hey guys just need a little help. I need to create a little script that clicks a link automatically and opens it up in a new page. So far I have this: Code: <head> <script> function autoClick(){ document.getElementById('linkToClick').click(); } </head> <body onload="setTimeout('autoClick();',3000);"> <a id="linkToClick" href="http://www.google.com" rel="nofollow" target="_blank">GOOGLE</a> </body> It works but the problem is that IE popup blocker keeps blocking the new window. Is there a way to do the same thing with javascript without it having blocked by IE popup blocker? Dear all, Can anyone help me with this… I do not know if this is possible to be done… Instead of text: "Your favorite color is <b>Green</b> right?" I need to show form like this: Code: <form action="auto.htm" method="get" > Your state<br> <select name="statecode" id="statecode"> <option value="">Choose State...</option> <option value="AK">Alaska</option> <option value="AL">Alabama</option> <option value="AR">Arkansas</option> </select> <input type="submit" name="search" value="Get Quotes" /> </form> Thank you in advance This is code I wish to modify. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> html,body { padding:0; height:100%; } #right { width:500px; height:100%; background-color:#999; text-align:center; float:right; } #left { height:100%; margin-right:500px; background-color:#f00; text-align:center; } </style> <script type="text/javascript"> function change() { switch (document.getElementById("select").value) { case "1": document.getElementById("change").innerHTML = "Your favorite color is <b>Green</b> right?" break; case "2": document.getElementById("change").innerHTML = "Your favorite color is <b>Red</b> right?" break; case "3": document.getElementById("change").innerHTML = "Your favorite color is <b>Yellow</b> right?" break; } } </script> </head> <body> What is your favorite color <select onchange="change()" id="select"> <option value="">------</option> <option value="1">Green</option> <option value="2">Red</option> <option value="3">Yellow</option> </select> <div id="change" style="margin:10px;width:200px;height:100px;padding:5px;"> Original Text </div> </body> </html> |