Note that there are some explanatory texts on larger screens.

plurals
  1. POchange image based on increment parameter
    text
    copied!<p>i'm building a website here and i'm struggling for something that bothers me i'm trying to make a increment button that will change image depends on the increment parameter for example if the value is'0', the picture is 'a' then i increment it, the value is '1, and the picture is 'b' and so on i did some code here</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;Image Change Demo&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; &lt;script type="text/javascript"&gt; function increaseValue ( eleId ) { var ele = document.getElementById(eleId); ele.value = parseInt(ele.value) + 1;} function decreaseValue ( eleId ) { var ele = document.getElementById(eleId); if(ele.value!=0){ ele.value = parseInt(ele.value) - 1; }}; function changeIt(imageName,objName) { var obj = document.getElementById(objName); var imgTag = "&lt;img src='"+imageName+"' border='0' /&gt;"; obj.innerHTML = imgTag; return; }; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="image1"&gt; &lt;img src="1.jpg" border="0" alt="" /&gt; &lt;/div&gt; &lt;br&gt;&lt;br&gt; &lt;input type="text" value="1" id="incrementer" /&gt; &lt;input type="button" value="+" onclick="increaseValue('incrementer'),changeIt('button/next.png','image1');"&gt; &lt;input type="button" value="-" onclick="decreaseValue('incrementer'),changeIt('button/plus.png','image1');"&gt; &lt;/html&gt; </code></pre> <p>can anyone help ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload