Search Results

Search found 2007 results on 81 pages for 'getelementbyid'.

Page 5/81 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Resizing Images In a Table Using JavaScript

    - by Abluescarab
    Hey, all. I apologize beforehand if none of this makes sense, or if I sound incompetent... I've been making webpages for a while, but don't know any JavaScript. I am trying to make a webpage for a friend, and he requested if I could write some code to resize the images in the page based on the user's screen resolution. I did some research on this question, and it's kind of similar to this, this, and this. Unfortunately, those articles didn't answer my question entirely because none of the methods described worked. Right now, I have a three-column webpage with 10 images in a table in the left sidebar, and when I use percentages for their sizes, they don't resize right between monitors. As such, I'm trying to write a JavaScript function that changes their sizes after detecting the screen resolution. The code is stripped from my post if I put it all, so I'll just say that each image links to a website and uses a separate image to change color when you hover over it. Would I have to address both images to change their sizes correctly? I use a JavaScript function to switch between them. Anyway, I tried both methods in this article and neither worked for me. If it helps, I'm using Google Chrome, but I'm trying to make this page as cross-browser as possible. Here's the code I have so far in my JavaScript function: function resizeImages() { var w = window.width; var h = window.height; var yuk = document.getElementById('yuk').style; var wb = document.getElementById('wb').style; var tf = document.getElementById('tf').style; var lh = document.getElementById('lh').style; var ko = document.getElementById('ko').style; var gz = document.getElementById('gz').style; var fb = document.getElementById('fb').style; var eg = document.getElementById('eg').style; var dl = document.getElementById('dl').style; var da = document.getElementById('da').style; if (w = "800" && h = "600") { } else if (w = "1024" && h = "768") { } else if (w = "1152" && h = "864") { } else if (w = "1280" && h = "720") { } else if (w = "1280" && h = "768") { } else if (w = "1280" && h = "800") { } else if (w = "1280" && h = "960") { } else if (w = "1280" && h = "1024") { } } Yeah, I don't have much in it because I don't know if I'm doing it right yet. Is this a way I can detect the "width" and "height" properties of a window? The "yuk", "wb", etcetera are the images I'm trying to change the size of. To sum it up: I want to resize images based on screen resolution using JavaScript, but my research attempts have been... futile. I'm sorry if that was long-winded, but thanks ahead of time!

    Read the article

  • innter.HTML not working after submit button is clicked

    - by user1781453
    I am trying to get the innerHTML to change to what is in the end of the function "calculate" but nothing happens once I hit submit. Here is my code: Pizza Order Form .outp {border-style:solid;background-color:white; border-color:red;padding:1em; border-width: .5em;} .notes {font-size:smaller;font-style:italic;} p {margin-left: 15%; width: 65%;} textarea {resize : none;} </style> function calculate(){ var type; var newline=""; var sum=0; var toppings=""; if( document.getElementById("small").checked==true){ type="Small Pizza"; sum+=4; } if( document.getElementById("medium").checked==true){ type="Medium Pizza"; sum+=6; } if( document.getElementById("large").checked==true){ type="Large Pizza"; sum+=8; } if( document.getElementById("pepperoni").checked==true){ toppings=toppings+"pepperoni, "; sum+=0.75; } if( document.getElementById("olives").checked==true){ toppings=toppings+"olives, "; sum+=0.6; } if( document.getElementById("sausage").checked==true){ toppings=toppings+"sausage, "; sum+=0.75; } if( document.getElementById("peppers").checked==true){ toppings=toppings+"peppers, "; sum+=0.5; } if( document.getElementById("onions").checked==true){ toppings=toppings+"onions, "; sum+=0.5; } if( document.getElementById("cheese").checked==true){ toppings=toppings+"Cheese Only, "; } var length = toppings.length; toppings = toppings.slice(0,length-2); document.getElementById("opta").innerHTML = type+newline+"Toppings:"+newline+toppings+newline+"Price - $"+sum; } Joe's Pizza Palace On-line Order Form <p id = "op" class = "outp" > <b /> Select the size Pizza you want: &nbsp;&nbsp; <input type="radio" name = "size" id="small" value = "small"> Small - $4.00 <b /> <input type="radio" name = "size" id="medium" value = "medium"> Medium - $6.00 <b /> <input type="radio" name = "size" id="large" value = "large"> Large - $8.00 <b /> </p> <p id = "op1" class = "outp" > <b /> Select the toppings: &nbsp;&nbsp; <input type="checkbox" name = "size" id="pepperoni" value = "pepperoni"> Pepperoni ($0.75) <b /> <input type="checkbox" name = "size" id="olives" value = "olives"> Olives ($0.60) <b /> <input type="checkbox" name = "size" id="sausage" value = "sausage"> Sausage ($0.75) <b /> <br /> <input type="checkbox" name = "size" id="peppers" value = "peppers"> Peppers ($0.50) <b /> <input type="checkbox" name = "size" id="onions" value = "onions"> Onions ($0.50) <b /> <input type="checkbox" name = "size" id="cheese" value = "cheese"> Cheese Only <b /> To obtain the price of your order click on the price button below: <br /><br /> <input type="button" align = "left" onclick="calculate();" value="Price (Submit Button)"/> <input type="reset" align = "left" value="Clear Form"/> <br /><br /> <textarea class="outp3" id="opta" style="border-color:black;" rows="6" cols="40" > </textarea>

    Read the article

  • Javascript: Check if checkboxes are selected on page load and add a class to parent html li

    - by BoDiE2003
    Im looking a way to do it with prototype, this js, needs to loads with the page and interate over all the elements (inputs - checkboxes, in this case) with the given id and assign a class to its parent <li></li> The JS is: function changeSelectionStyle(id) { var inputId = id.substr(0,id.length-2); if(document.getElementById(inputId).checked){document.getElementById(id).className = 'yes';} alert(document.getElementById(inputId).checked); /* * if(document.getElementById(id).className != 'yes'){ * document.getElementById(id).className = 'yes'; * } else{document.getElementById(id).className = '';} */ } And the HTML (piece of it) that interacts with this JS is: <li id="selectedAuthorities-4_1li"> <input type="checkbox" id="selectedAuthorities-4_1" name="selectedAuthorities" value="ROLE_ADD_COMMENT_TO_CV" checked="checked" onclick="changeSelectionStyle(this.id + 'li'); checkFatherSelection(this.id);"> <a href="#" onclick="document.getElementById('selectedAuthorities-4_1').click(); return false;"> Agregar comentario <samp><b></b>Permite agregar comentario en el detalle</samp> </a> </li> After iteration, checking is the checkbox is checked, it has to add the class="yes" to the <li id="selectedAuthorities-4_1li">

    Read the article

  • Javascript onclick event is not working in internet explorer 8.

    - by Mallika Iyer
    Hi, I have the following line of code that works fine in Firefox, Chrome and Safari, but not in internet explorer 8. <a href="javascript:void(0);" onclick="showHide('reading','type_r','r');">Show me the example</a> The function simply shows and hides a div on clicking the hyperlink. Is there anything I'm missing here? This is the showHide function: function showHide(elementId,parentId,qtype) { if (document.getElementById && !document.all) { var elementParent = document.getElementById(parentId); var element = document.getElementById(elementId); var upArrowId = 'up-arrow-'+qtype; var downArrowId = 'down-arrow-'+qtype; if(element.style.visibility == 'hidden'){ elementParent.style.height = 'auto'; element.style.visibility = 'visible'; document.getElementById(upArrowId).style.visibility = 'visible'; document.getElementById(downArrowId).style.visibility = 'hidden'; } else if(element.style.visibility == 'visible'){ element.style.visibility = 'hidden'; elementParent.style.height = '50px'; document.getElementById(upArrowId).style.visibility = 'hidden'; document.getElementById(downArrowId).style.visibility = 'visible'; } } } Thanks.

    Read the article

  • IE8 error when using dyanamic form actions

    - by user330711
    Hello all: Please go here to see an iframe based web app. Click on the map of Australia, choose a city, then buy some tickets. Now you will see the cart form located on the lower right corner. The problem is in IE8, I cannot delete checked rows from the table; whereas in other browsers such as FireFox3.6, Opera10, Safari4 and Chrome4, this action is all right. Below is the related javascript. It doesn't use jQuery, as part of the requirement is no framework allowed! And iframes are the my best bet, ajax will simply kill me under this restriction. /* cartForm.js */ function toDeleteRoutes() //this function is executed before form is to be submitted. { if(document.getElementsByClassName('delete_box').length > 0) //there're rows to delete { document.getElementById('cartForm').action ="./deleteRoutes.php"; document.getElementById('cartForm').target ="section4"; return true; //this enables the form to be submitted as usual. } else return false; //there is no more row in table to delete! } function toSendEmail() //this function is executed before form is to be submitted. { document.getElementById('cartForm').action ="./sendEmail.php"; document.getElementById('cartForm').target ="section3"; document.getElementById('delete_btn').disabled = true; //disable delete button now return true; //this enables the form to be submitted as usual. } function toCancelPurchase() { document.getElementById('cartForm').action ="./cancelPurchase.php"; document.getElementById('cartForm').target ="section4"; return true; //this enables the form to be submitted as usual. } I don't know which part is wrong, or this is just because IE8 screws all?

    Read the article

  • Javascript trouble changing opacity

    - by Ghilliedrone
    I'm making script that fades 3 pictures out in order, but the pictures' opacity aren't changing. The if statements are reached but the pictures do not change. The first picture changes to 1 opacity on the page load, so I don't see why it wouldn't work in my function. window.onload = function() { document.getElementById("img1").style.opacity = 1; setInterval(swapPictures, 2000); }; var swapPictures = function(){ if(typeof swapPictures.img1v === 'undefined'){ swapPictures.img1v = true; } if(typeof swapPictures.img2v === 'undefined'){ swapPictures.img2v = false; } if(typeof swapPictures.img3v === 'undefined'){ swapPictures.img3v = false; } if(swapPictures.img1v && !swapPictures.img2v && !swapPictures.img3v){ swapPictures.img1v = !swapPictures.img1v; swapPictures.img2v = !swapPictures.img2v; document.getElementById("img1").style.opacity = .4; document.getElementById("imgtwo").style.opactiy = 1; }else if(!swapPictures.img1v && swapPictures.img2v && !swapPictures.img3v){ swapPictures.img2v = !swapPictures.img2v; swapPictures.img3v = !swapPictures.img3v; document.getElementById("imgtwo").style.opacity = .4; document.getElementById("imgthree").style.opactiy = 1; }else if(!swapPictures.img1v && !swapPictures.img2v && swapPictures.img3v){ swapPictures.img3v = !swapPictures.img3v; swapPictures.img1v = !swapPictures.img1v; document.getElementById("imgthree").style.opacity = .4; document.getElementById("img1").style.opactiy = 1; } };

    Read the article

  • CSS Ease-in-out to full screen

    - by Aditya Singh
    I have a black background div of a size which contains an image. <div id="Banner"> <img onclick="expand();" src="hola.jpg"> </div> #Banner { position:relative; height:50px; width:50px; margin:0 auto; background-color:#000000; -webkit-transition: all 0.5s ease-in-out 0.5s; -moz-transition: all 0.5s ease-in-out 0.5s; -o-transition: all 0.5s ease-in-out 0.5s; transition: all 0.5s ease-in-out 0.5s; } <script type="text/javascript"> function expand(){ document.getElementById('Banner').style['height'] = '250'; document.getElementById('Banner').style['width'] = '250'; } </script> So when the user clicks on the image, the div transitions to 250, 250. My problem is that, i want it to to transition to full screen. The following javascript function does expand to fullscreen but the transition effect doesn't come. I need to do it from a javascript code without jquery. function expand(){ document.getElementById('Banner').style['position'] = 'absolute'; document.getElementById('Banner').style['height'] = '100%'; document.getElementById('Banner').style['width'] = '100%'; document.getElementById('Banner').style['top'] = '0'; document.getElementById('Banner').style['left'] = '0'; } Please advice. Update : Solution Roger below has provided with an alternative solution. This takes care if the document has already been scrolled and is another place. Will expand the div to full browser screen. sz=getSize(); //function returns screen width and height in pixels currentWidth=200; currentHeight=200; scalex=sz.W/currentWidth; scaley=sz.H/currentHeight; transx=0-((expandingDiv.offsetLeft+(currentWidth/2))-(sz.W/2))+document.body.scrollLeft; transy=0-((expandingDiv.offsetTop+(cuttentHeight/2))-(sz.H/2))+document.body.scrollTop; transx = transx.toString(); transy = transy.toString(); document.getElementById("Banner").style['-webkit-transform'] = 'translate('+transx+'px,'+transy+'px) scale('+scalex+','+scaley+')';

    Read the article

  • having problems with javascript null

    - by user165242
    I have tried rectifying the code below. But I am not able to find a solution. After executing the code, firebug says "document.getElementById(haystack.value) is null". I tried if(document.getElementById(haystack).value ==null) but it was of no use. Please help me out. var haystack=document.getElementById('city1').value; if(!document.getElementById(haystack).value) { alert("null"); } else { alert("not null"); }

    Read the article

  • What is wrong with this javascript?

    - by bala3569
    i use this javascript syntax for validating a checkbox... alert(document.getElementById("ctl00_ContentPlaceHolder1_Chkreg").checked); if (document.getElementById("ctl00_ContentPlaceHolder1_Chkreg").checked == false) { document.getElementById("ctl00_ContentPlaceHolder1_ErrorMsg").innerHTML = "please select the checkbox"; document.getElementById("ctl00_ContentPlaceHolder1_Chkreg").focus(); return false; } My alert showed me false but my if loop is not working... Any suggestion...

    Read the article

  • How to change h:outputText value by JavaScript?

    - by Peter
    I already tested with 2 inputText, It runs well for example var tdate = document.getElementById('txtDate'); //h:inputText var tdt = document.getElementById('txtDateTime'); //h:inputText tdate.onchange = function(){ tdt.value = tdate.value; }; How can I change the value of " tdt " - h:outputText? var tdate = document.getElementById('txtDate'); //h:inputText var tdt = document.getElementById('txtDateTime'); //h:outputText

    Read the article

  • Why wont this JS code work if its all on the same line?

    - by culov
    I'm writing HTML code for a java servlet. i first write the code in html/js so i can debug what im working on, and then ill make it a java string and put it in my servlet. My problem is that the code is working fine when i view it in ff from a local html file, but when i view it on my java servlet, it doesnt work because the js isnt getting called. what I did was format the html that my servlet generated so that its not all on a single line and ran the code again. This time it worked. I copied this working code into a browser address bar so that it will all be on a single line, and copied that code back into the script in my html file. Now, when the previously working code is on a single line, it doesnt work. Here's the formatted JS: var sMax var holder; var preSet; var rated; var request; function rating(num){ sMax = 0; for(n=0; n<num.parentNode.childNodes.length; n++){ if(num.parentNode.childNodes[n].nodeName == "A"){ sMax++; } } if(!rated){ s = num.id.replace("_", ''); a = 0; for(i=1; i<=sMax; i++){ if(i<=s){ document.getElementById("_"+i).className = "on"; document.getElementById("rateStatus").innerHTML = num.title; holder = a+1; a++; }else{ document.getElementById("_"+i).className = ""; } } } } function off(me){ if(!rated){ if(!preSet){ for(i=1; i<=sMax; i++){ document.getElementById("_"+i).className = ""; document.getElementById("rateStatus").innerHTML = me.parentNode.title; } }else{ rating(preSet); document.getElementById("rateStatus").innerHTML = document.getElementById("ratingSaved").innerHTML; } } } function rateIt(me){ if(!rated){ document.getElementById("rateStatus").innerHTML = document.getElementById("ratingSaved").innerHTML + " "+me.title; preSet = me; rated=1; sendRate(me); rating(me); } } function sendRate(sel){ alert("Your rating was: "+sel.title); addRating("rating", "?truck=kogibbq?rating="+ sel.id); } function addRating(servletName, servletArguments){ var servlet = servletName; var arg = servletArguments var req = servlet + arg; alert(req); addrequest(req); request.onreadystatechange = function(){ alert("response received"); } } function addrequest(req) { try { request = new XMLHttpRequest(); }catch (e) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); }catch (e) { alert("XMLHttpRequest error: " + e); } } request.open("GET", element, true); request.send(null); return request; } Thanks.

    Read the article

  • Javascript works great locally, but not on my server

    - by Jonathan Cohen
    I'm teaching myself javascript by creating a script for displaying an external rss feed on a webpage. The code I patched together works great locally. This is a screen grab of the code producing exactly the desired behavior. The code is populating all the information inside the section "Blog: Shades of Gray", except for "tagged" which I hard coded: But when I upload the site files to my server, the code doesn't work at all. This is a screen grab of the code on my site NOT producing the desired behavior... This feels like I'm not getting something really basic about how javascript works locally vs. on the server. I did my half hour of googling for an answer and no trails look promising. So I'd really appreciate your help. This is my site (under construction) http://jonathangcohen.com Below is the code, which can also be found at http://jonathangcohen.com/grabFeeds.js. /*Javascript for Displaying an External RSS Feed on a Webpage Wrote some code that’ll grab attributes from an rss feed and assign IDs for displaying on a webpage. The code references my Tumblr blog but it’ll extend to any RSS feed.*/ window.onload = writeRSS; function writeRSS(){ writeBlog(); } function writeBlog(){ if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","http://blog.jonathangcohen.com/rss.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; var x=xmlDoc.getElementsByTagName("item"); //append category to link for (i=0;i<3;i++) { if (i == 0){ //print category var blogTumblrCategory = x[i].getElementsByTagName("category")[0].childNodes[0].nodeValue document.getElementById("getBlogCategory1").innerHTML = '<a class="BlogTitleLinkStyle" href="http://blog.jonathangcohen.com/tagged/'+blogTumblrCategory+'">'+blogTumblrCategory+'</a>'; //print date var k = x[i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue thisDate = new Date(); thisDate = formatTumblrDate(k); document.getElementById("getBlogPublishDate1").innerHTML = thisDate; //print title var blogTumblrTitle = x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue var blogTumblrLink = x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue document.getElementById("getBlogTitle1").innerHTML = '<a class="BlogTitleLinkStyle" href="'+blogTumblrLink+'">'+blogTumblrTitle+'</a>'; } if (i == 1){ //print category var blogTumblrCategory = x[i].getElementsByTagName("category")[0].childNodes[0].nodeValue document.getElementById("getBlogCategory2").innerHTML = '<a class="BlogTitleLinkStyle" href="http://blog.jonathangcohen.com/tagged/'+blogTumblrCategory+'">'+blogTumblrCategory+'</a>'; //print date var k = x[i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue thisDate = new Date(); thisDate = formatTumblrDate(k); document.getElementById("getBlogPublishDate2").innerHTML = thisDate; //print title var blogTumblrTitle = x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue var blogTumblrLink = x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue document.getElementById("getBlogTitle2").innerHTML = '<a class="BlogTitleLinkStyle" href="'+blogTumblrLink+'">'+blogTumblrTitle+'</a>'; } if (i == 2){ //print category var blogTumblrCategory = x[i].getElementsByTagName("category")[0].childNodes[0].nodeValue document.getElementById("getBlogCategory3").innerHTML = '<a class="BlogTitleLinkStyle" href="http://blog.jonathangcohen.com/tagged/'+blogTumblrCategory+'">'+blogTumblrCategory+'</a>'; //print date var k = x[i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue thisDate = new Date(); thisDate = formatTumblrDate(k); document.getElementById("getBlogPublishDate3").innerHTML = thisDate; //print title var blogTumblrTitle = x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue var blogTumblrLink = x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue document.getElementById("getBlogTitle3").innerHTML = '<a class="BlogTitleLinkStyle" href="'+blogTumblrLink+'">'+blogTumblrTitle+'</a>'; } } } function formatTumblrDate(k){ d = new Date(k); var curr_date = d.getDate(); var curr_month = d.getMonth(); curr_month++; var curr_year = d.getFullYear(); printDate = (curr_month + "/" + curr_date + "/" + curr_year); return printDate; } Thank you!

    Read the article

  • Dual AJAX Requests at different times

    - by Nik
    Alright, I'm trying to make an AJAX Chat system that polls the chat database every 400ms. That part is working, the part of which isn't is the Active User List. When I try to combine the two requests, the first two requests are made, then the whole thing snowballs and the usually timed (12 second) Active User List request starts updating every 1ms and the first request NEVER happens again. Displayed is the entire AJAX code for both requests: var waittime=400;chatmsg=document.getElementById("chatmsg"); room = document.getElementById("roomid").value; chatmsg.focus() document.getElementById("chatwindow").innerHTML = "loading..."; document.getElementById("userwindow").innerHTML = "Loading User List..."; var xmlhttp = false; var xmlhttp2 = false; var xmlhttp3 = false; function ajax_read(url) { if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType){ xmlhttp.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) { document.getElementById("chatwindow").innerHTML = xmlhttp.responseText; setTimeout("ajax_read('methods.php?method=r&room=" + room +"')", waittime); } } xmlhttp.open('GET',url,true); xmlhttp.send(null); } function user_read(url) { if(window.XMLHttpRequest){ xmlhttp3=new XMLHttpRequest(); if(xmlhttp3.overrideMimeType){ xmlhttp3.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp3=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp3=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp3) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } xmlhttp3.onreadystatechange = function() { if (xmlhttp3.readyState==4) { document.getElementById("userwindow").innerHTML = xmlhttp3.responseText; setTimeout("ajax_read('methods.php?method=u&room=" + room +"')", 12000); } } xmlhttp3.open('GET',url,true); xmlhttp3.send(null); } function ajax_write(url){ if(window.XMLHttpRequest){ xmlhttp2=new XMLHttpRequest(); if(xmlhttp2.overrideMimeType){ xmlhttp2.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp2) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } xmlhttp2.open('GET',url,true); xmlhttp2.send(null); } function submit_msg(){ nick = document.getElementById("chatnick").value; msg = document.getElementById("chatmsg").value; document.getElementById("chatmsg").value = ""; ajax_write("methods.php?method=w&m=" + msg + "&n=" + nick + "&room=" + room + ""); } function keyup(arg1) { if (arg1 == 13) submit_msg(); } var intUpdate = setTimeout("ajax_read('methods.php')", waittime); var intUpdate = setTimeout("user_read('methods.php')", waittime);

    Read the article

  • javascript div positioning

    - by sam
    hello folks., please suggest me a solution.. i am using this script to display an image as popup on mouseover.. the difficulty i am facing is that it is not positioning well in different monitor.. it must be something to do with pixcel.. function LargeImage(obj,e) { var imgbtn=document.getElementById('<%=imgbtn1.ClientID%'); imgbtn.src=obj; document.getElementById('imgbox').style.visibility="visible"; document.getElementById('imgbox').style.position="absolute"; document.getElementById('imgbox').style.left=e.clientX-150 + "px"; document.getElementById('imgbox').style.top=225 +"px"; //225 +"px"; } thank you

    Read the article

  • Dashcode newbie question: Change a button's label programmatically

    - by Koning Baard XIV
    Hi all! I'm new to Mac OS X Dashboard developement. Now, I have a button with id b_start. When that button is clicked, I want the label of the button to change to "Round". Now I have tried these, but none of them work: document.getElementById("b_start").label = "Round"; document.getElementById("b_start").text = "Round"; document.getElementById("b_start").innerText = "Round"; document.getElementById("b_start").object.setValue("Round"); document.getElementById("b_start").value = "Round"; Does anyone how I can change the button's label? Thanks in advance.

    Read the article

  • How to show error message with jquery tooltip?

    - by bala3569
    I am validating my controls in a form... if a control is empty i would like to show a jquery tooltip with that error msg.. Here is what i am doing... if (document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline") .selectedIndex == -1) { document.getElementById("ctl00_ContentPlaceHolder1_ErrorMsg").innerHTML = "please select your Discipline"; document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline").focus(); return false; } and i would like to do like this, if (document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline") .selectedIndex == -1) { // show tooltip besides the control with the error message... document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline").focus(); return false; } Any suggestion...

    Read the article

  • Defining functions and if statement problems

    - by David Fairbairn
    I'm having a problem with two functions and an if statement. I'm being told the functions go and postcodeChange are not defined. I'm also being told flag is an unexpected identifier at if flag == 1. Any idea where I am going wrong? Thank you. function postcodeChange(){ document.getElementById("goButton").onclick = distanceCheck; } function distanceCheck(){ var distance = document.getElementById("distance").value var patt1=new RegExp("^[0-9]+(\.[0-9]{1})?$"); var out = patt1.exec(distance); if (out == null) { //distance is not a valid number document.getElementById("distanceFlag").value = 1 } else { //distance is valid number document.getElementById("distanceFlag").value = 0 } function go(){ var flag = document.getElementById("distanceFlag").value if flag == 1 { alert("Distance is not valid- enter a number with no more than one decimal point"); } else{ popSubmit('#fa Care Provider Search Go','','0'); } }

    Read the article

  • What is the problem with this code?

    - by Giffyguy
    The compile error I'm getting is "newline in constant" The error occurs where the four asterisks are (****). I can't debug, because the solution won't build successfully. <script type="text/javascript"> function TNClicked(fullImgURL, TNID) { document.getElementById("<%= this.imgFull.ClientID %>").src = fullImgURL; var pnlFullImage = document.getElementById("<%= this.pnlFullImage.ClientID %>"); if (pnlFullImage.style.visibility != "visible") pnlFullImage.style.visibility = "visible"; document.getElementById("<%= this.tcImage.ClientID %>").innerHTML = TNID; //document.forms[0].ctl00$ctl00$ctl00$cntBody$hfImage.value = TNID; //****document.getElementById("<%= this.hfImage").setAttribute("value", TNID); //document.getElementById("<%= this.hfImage.ClientID %>").value = TNID; } </script>

    Read the article

  • jQuery getting these functions to work together

    - by brett
    I'm new to jQuery and have tried looking around for an answer on how to do this. I have 2 functions and I would like both to work together. The one function is submitHandler and its used to hide a form and at the same time add a class to a hidden element to unhide it - ie a thank you for submitting h1. The other function is to grab the input data and display it onsubmit in the form. So the problem is that I can get that one to work but then the other doesnt. Ie on form submit I can see the data input but not the h1 Thank you message. Here are the functions: SubmitHandler: submitHandler: function() { $("#content").empty(); $("#content").append( "<p>If you want to be kept in the loop...</p>" + "<p>Or you can contact...</p>" ); $('h1.success_').removeClass('success_').addClass('success_form'); $('#contactform').hide(); }, onsubmit="return inputdata()" function inputdata(){ var usr = document.getElementById('contactname').value; var eml = document.getElementById('email').value; var msg = document.getElementById('message').value; document.getElementById('out').innerHTML = usr + " " + eml + msg; document.getElementById('out').style.display = "block"; return true; }, The form uses PHP and jQuery - I dont know about AJAX but after some reading even less sure. Please help me out I dont know what I'm doing and at the moment I am learning but its a long road for me still. Thank you The form: <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform" onsubmit="return inputdata()"> <div class="_required"><p class="label_left">Name*</p><input type="text" size="50" name="contactname" id="contactname" value="" class="required" /></div><br/><br/> <div class="_required"><p class="label_left">E-mail address*</p><input type="text" size="50" name="email" id="email" value="" class="required email" /></div><br/><br/> <p class="label_left">Message</p><textarea rows="5" cols="50" name="message" id="message" class="required"></textarea><br/> <input type="submit" value="submit" name="submit" id="submit" /> </form> The PHP bit: <?php $subject = "Website Contact Form Enquiry"; //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['contactname']) == '') { $hasError = true; } else { $name = trim($_POST['contactname']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['message']) == '') { $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } //If there is no error, send the email if(!isset($hasError)) { $emailTo = '[email protected]'; //Put your own email address here $body = "Name: $name \n\nEmail: $email \n\nComments:\n $comments"; $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ? The Jquery Validate bit: $(document).ready(function(){ $('#contactform').validate({ showErrors: function(errorMap, errorList) { //restore the normal look $('#contactform div.xrequired').removeClass('xrequired').addClass('_required'); //stop if everything is ok if (errorList.length == 0) return; //Iterate over the errors for(var i = 0;i < errorList.length; i++) $(errorList[i].element).parent().removeClass('_required').addClass('xrequired'); }, Here is the full jQuery bit: $(document).ready(function(){ $('#contactform').validate({ showErrors: function(errorMap, errorList) { //restore the normal look $('#contactform div.xrequired').removeClass('xrequired').addClass('_required'); //stop if everything is ok if (errorList.length == 0) return; //Iterate over the errors for(var i = 0;i < errorList.length; i++) $(errorList[i].element).parent().removeClass('_required').addClass('xrequired'); }, submitHandler: function() { $('h1.success_').removeClass('success_').addClass('success_form'); $("#content").empty(); $("#content").append('#sadhu'); $('#contactform').hide(); }, }); }); Latest edit - Looks like this: $(document).ready(function(){ $('#contactform').validate({ showErrors: function(errorMap, errorList) { //restore the normal look $('#contactform div.xrequired').removeClass('xrequired').addClass('_required'); //stop if everything is ok if (errorList.length == 0) return; //Iterate over the errors for(var i = 0;i < errorList.length; i++) $(errorList[i].element).parent().removeClass('_required').addClass('xrequired'); }, function submitHandler() { $('h1.success_').removeClass('success_').addClass('success_form'); $("#content").empty(); $("#content").append('#sadhu'); $('#contactform').hide(); }, function inputdata() { var usr = document.getElementById('contactname').value; var eml = document.getElementById('email').value; var msg = document.getElementById('message').value; document.getElementById('out').innerHTML = usr + " " + eml + msg; document.getElementById('out').style.display = "block"; }, $(document).ready(function(){ $('#contactForm').submit(function() { inputdata(); submitHandler(); }); }); });

    Read the article

  • php drop down how to control the hide and show

    - by user329394
    Hi all, i want to control the drop down box to control show or hide statement. I do like this but it seems it doesn't work, i have it working if im using radio button. can help me with the code? which part am i wrong? thank you. $dbcnx = mysql_connect('localhost', 'root', ''); mysql_select_db('dbase'); if($_POST['gred'])$gred=$_POST['gred'];else $gred=""; <script language="JavaScript"> function funcHide(elemHide1,elemHide2,elemHide3) { document.getElementById(elemHide1).style.display = 'none'; document.getElementById(elemHide2).style.display = 'none'; document.getElementById(elemHide3).style.display = 'none'; document.getElementById(elemShow).style.visibility = 'visible'; } function funcShow(elemShow1,elemShow2,elemShow3) { document.getElementById(elemShow1).style.display = 'block'; document.getElementById(elemShow2).style.display = 'block'; document.getElementById(elemShow3).style.display = 'block'; document.getElementById(elemShow1).style.visibility = 'visible'; document.getElementById(elemShow2).style.visibility = 'visible'; document.getElementById(elemShow3).style.visibility = 'visible'; } </script> <table> <tr> <td>Gred </td> <td>:</td> <td><select name="gred" id="gred"> <option value="">&nbsp;</option> <option value="A17" <?php if($gred=='A17')echo "selected";?> onClick="funcShow('box1', 'box2', 'box3');">A17</option> <option value="A22" <?php if($gred=='A22')echo "selected";?>>A22</option> <option value="A27" <?php if($gred=='A27')echo "selected";?>>A27</option> </select> </td> </tr> <tr> <td>TK</td> <td>:</td> <td> <select name="tk" id="tk"> <option value="">&nbsp;</option> <option value="01" <?php if($tk=='01')echo "selected";?>>01</option> <option value="02" <?php if($tk=='02')echo "selected";?>>02</option> <option value="03" <?php if($tk=='03')echo "selected";?>>03</option> <option value="04" <?php if($tk=='04')echo "selected";?>>04</option> <option value="05" <?php if($tk=='05')echo "selected";?>>05</option> <option value="06" <?php if($tk=='06')echo "selected";?>>06</option> </select> <?} ?> </td> </tr> <tr> <td colspan="2" valign="top">Status</td> <td valign="top">:</td> <td> <?php $qry = "SELECT * from dtable where userid='".$USER->id."'"; $sql = mysql_query($qry); $row = mysql_num_rows($sql); if($row==0) { ?> <input type=radio name="status" <?php if($status=='retake') {?>checked="checked"<?php } ?> value="retake" onClick="funcShow('box1', 'box2', 'box3');">Retake<br /></tr> <tr> <td colspan='2'> <div id="box1" style="display: none;">Last Date <br> Latest Date<br> </div></td> <td><div id="box2" style="display: none;">: <br> : <br></div></td> <td> <div id="box3" style="display: none;"> <?php $rsu[lastdate] ?> <br> <?php $rsu[latestdate] ?> </div> </td>

    Read the article

  • remove spaces in string using javascript

    - by reza saberi
    I need to do some functions on some text field contents before submitting the form, like checking the validity of the customer registeration code, having the customer name as his code in customers table appending an incrementing number. I don't want to do it after the form is submitted becuase I need it to be displayed in the code field before submitting the form. My code: function getCode(){ var temp = document.getElementById("temp").value ; var d = parseInt(document.getElementById("temp").value) + 1; document.getElementById("customernumber").value = d; document.getElementById("code").value = document.getElementById("name").value+"-"+ d; } It all works fine, but the last line of code developed the code WITH the spaces between the code.

    Read the article

  • How can I use innerHTML without delete the before innerHTML?

    - by Mikelon85
    I want to convert an Array to a HTML table, but innerHTML deletes it writes before. Here is the code: <html><div id="tablaP"></div> function cargar2() { document.getElementById('tablaP').innerHTML= "<table>" var h=1 for (i=0;i<miArray.length;i++){ document.getElementById('tablaP').innerHTML = '<tr>' for (j=0;j<miArray[i].length;j++){ document.getElementById("tablaP").innerHTML = '<td><td>' } document.getElementById('tablaP').innerHTML = '</tr>' h++ } document.getElementById('tablaP').innerHTML = '</table>' }

    Read the article

  • Why this script is not validating the form

    - by danishjan
    This is registration form code. i wrote script in one i have accessed every element by Id and in One by name but both donot validation it. <div id="form"> <form action="" method="get" id="formdata" > <p> <label for="firstName" class="labels">&nbsp; &nbsp;First Name </label> <input type="text" name="firstName" id="firstName" placeholder="First Name" /> <label for="firstName" id="errorfirstName" style="color:red; font- size:14px; visibility:hidden;"> Please Enter First Name </label> </p> <p> <label for="lastName" class="labels">&nbsp; &nbsp;Last Name </label> <input type="text" name="lastName" id="lastName" placeholder="Last Name" /> <label for="lastName" id="errorlastName" style="color:red; font-size:14px; visibility:hidden;"> Please Enter Last Name</label> </p> <p> <label for="fatherName" class="labels">Father Name</label> <input type="text" name="fatherName" id="fatherName" placeholder="Father Name" /> <label for="fatherName" id="errorfatherName" style="color:red; font- size:14px; visibility:hidden;"> Please Enter Father Name </label> </p> <p> <label for="classNo" class="labels">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Class </label> <input type="text" name="classNo" id="classNo" placeholder="Class" /> <label for="classNo" id="errorclassNo" style="color:red; font-size:14px; visibility:hidden;"> Please Enter Class </label> </p> <p> <label for="address" class="labels">&nbsp; &nbsp; &nbsp; &nbsp;Address </label> <input type="text" name="address" id="address" placeholder="Address" /> <label for="address" id="erroraddress" style="color:red; font-size:14px; visibility:hidden;"> Please Enter Address </label> </p> <p> <input type="submit" value="Submit" onSubmit="return validate()" /> </p> </form> And the JavaScript Code is here. What is wrong with this code. This code is through accessing by Element Id. <script type="text\javascript"> function validate(){ var valid=true; var fname=document.getElementById("firstName"); var lname=document.getElementById("lastName"); var fathname=document.getElementById("fatherName"); var classno=document.getElementById("classNo"); var address=document.getElementById("address"); var errfname=document.getElementById("errorfirstName"); var errlname=document.getElementById("errorlastName"); var errfathname=document.getElementById("errorfatherName"); var errclass=document.getElementById("errorclass"); var erraddress=document.getElementById("erroraddress"); if(fname.value == ""){ errfname.style.visibility="visible"; valid=false; } if(lname.value == ""){ errlname.style.visibility="visible"; valid=false; } if(fathname.value == ""){ errfathname.style.visibility="visible"; valid=false; } if(classno.value == ""){ errclass.style.visibility="visible"; valid=false; } if(address.value == ""){ erraddress.style.visibility="visible"; valid=false; } return valid; } </script>

    Read the article

  • how to count checked checkboxes in different divs

    - by KMKMAHESH
    <head><title>STUDENT WISE EXAM BACKLOGS DISPLAY FOR EXAM REGISTRATION</title> <style type="text/css"> th { font-family:Arial; color:black; border:1px solid #000; } thead { display:table-header-group; } tbody { display:table-row-group; } td { border:1px solid #000; } </style> <script type="text/javascript" > function check_value(year,sem){ ysem="ys"+year+sem; var reg=document.registration.regulation.value; subjectsys="subjects"+year+sem; amountsys="amount"+year+sem; if(year==1){ if(sem==1){ var value_list = document.getElementById("ys11").getElementsByTagName('input'); } if(sem==2){ var value_list = document.getElementById("ys12").getElementsByTagName('input'); } }elseif(year==2){ if(sem==1){ var value_list = document.getElementById("ys21").getElementsByTagName('input'); } if(sem==2){ var value_list = document.getElementById("ys22").getElementsByTagName('input'); } }elseif(year==3){ if(sem==1){ var value_list = document.getElementById("ys31").getElementsByTagName('input'); } if(sem==2){ var value_list = document.getElementById("ys32").getElementsByTagName('input'); } }elseif(year==4){ if(sem==1){ var value_list = document.getElementById("ys41").getElementsByTagName('input'); } if(sem==2){ var value_list = document.getElementById("ys42").getElementsByTagName('input'); } } values = 0; for (var i=0; i<value_list.length; i++){ if (value_list[i].checked) { values=values+1; } } document.getElementById(subjectsys).value=values; if (values=="0") { document.getElementById(amountsys).innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById(amountsys).innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","fee.php?year="+year+"&reg="+reg+"&sem="+sem+"&sub="+values,true); xmlhttp.send(); } </script> </head> <form id="registration" name="registration" action=subverify.php method=POST></br></br> <center> Backlog Subjects for <b>08KN1A1219</b> </br></br> <table border='1'><tr> <th width='40'>&nbsp;</th><th width='90'>Regulation</th><th width='40'>Year</th> <th width='40'>Sem</th><th width='350'>Subname</th> <th width='70'>Internals</th><th width='70'>Externals</th> </tr><div id="ys41"><tr> <td width='40'><center><input type="checkbox" name="sub[]" value="344" onclick="check_value(4,1)"></center></td> <td width='90'><center>R07</center></td><td width='40'><center>4</center></td><td width='40'><center>1</center></td> <td width='350'>EMBEDDED SYSTEMS</td><td width='70'><center>18</center></td> <td width='70'><center>17</center></td></tr><tr><td colspan=5 align=right><b>Subjects: </b><input size=2 type=textbox id=subjects41 name=subjects41 value=0 maxlength=2 readonly=readonly></td> <td align=right><b>Amount :</b></td> <input type='hidden' name='regulation' id=regulationsubjects41 value='R07'> <td><div id="amount41"><input type="textbox" name="amountval41" value="0" size="5" maxlength="5" readonly="readonly"></div></td></tr></div><div id="ys42"><tr> <td width='40'><center><input type="checkbox" name="sub[]" value="527" onclick="check_value(4,2)"></center></td> <td width='90'><center>R07</center></td><td width='40'><center>4</center></td><td width='40'><center>2</center></td> <td width='350'>DESIGN PATTERNS</td><td width='70'><center>12</center></td> <td width='70'><center>14</center></td></tr><tr><td colspan=5 align=right><b>Subjects: </b><input size=2 type=textbox id=subjects42 name=subjects42 value=0 maxlength=2 readonly=readonly></td> <td align=right><b>Amount :</b></td> <input type='hidden' name='regulation' id=regulationsubjects42 value='R07'> <td><div id="amount42"><input type="textbox" name="amountval42" value="0" size="5" maxlength="5" readonly="readonly"></div></td></tr></div><tr><td colspan=7><center><b><div id="maintotal"><input type="textbox" name="maintotal" value="0" size="5" maxlength="5" readonly="readonly"></div></center></b></td></tr><tr></tr></table></br></br> <center><input type='hidden' name='htno' value='08KN1A1219'> <input type='submit' value='Register'></center></form></br> this is a output of a php file with using dynamic data in the form i want to count only the checkboxes in the div and it has to display in that subjectsdiv like subjects41 and subjects42 can any one please help me to update this javascript it passes some ajax request for displaying the fee

    Read the article

  • Question - Setting dynamic HTML using Javascript to iFrames on Windows Mobile 6.1 - IE Mobile6

    - by swaroop
    Hi Experts, (excuse me if this is not the right forum to post - i couldn't find anything related to non-native programming and related to this topic) I Am trying to set a dynamic HTML into an iFrame on the webpage. I have tried a couple of things but none of them seem to work. I m able to read the innerHTML but can't seem to update it. // Able to read using document.getElementById('iFrameIdentifier').innerHTML; // On Desktop IE, this code works document.getElementById('iFrameId').contentWindow.document.open(); document.getElementById('iFrameId').contentWindow.document.write(dynamicHTML); document.getElementById('iFrameId').contentWindow.document.close(); Ideally the same function should work as how it works for div's but it says 'Object doesn't support this method or property". I have also tried document.getElementById('iFrameId').document.body.innerHTML. This apparently replaces the whole HTML of the page and not just the innerHTML. I have tried out a couple of things and they didn't work document.getElementById('iFrameId').body.innerHTML document.frames[0].document.body.innerHTML My purpose is to have a container element which can contain dynamic HTML that's set to it. I've been using it well till now when I observed that the setting innerHTML on a div is taking increasing amount of time because of the onClicks or other JS methods that are attached to the anchors and images in the dynamic HTML. Appears the JS methods or the HTML is some how not getting cleaned up properly (memory leak?) Also being discussed - http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26185526.html#a32779090

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >