Jump to content

n000bie

Members
  • Posts

    81
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

n000bie's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello, What I am trying to do is send values (id of the item and a Boolean value ) to php through ajax while clicking on radio button. If the radio button is clicked for the first time get the price of the current item and add it to the total amount and if it is clicked for the second time deduct the total amount. This works if there is only one radio button on the page. Can anyone help me to make this work on multiple radio buttons. This is my html code <body> <h2>Item 1</h2> <table cellspacing="1" cellpadding="0" class="program"> <tbody><tr> <th></th> <th>Grade</th> <th>Name</th> <th>Location</th> <th>Days</th> <th>Price</th> </tr> <tr class="v"><td ><input type="radio" id="a" value="1" name="a" onclick="showData(this.value)" ></td><td>3</td><td>name of item1</td><td>location1</td><td>5</td><td class="price1">100</td></tr> </tbody> </table> <h2>Item 2</h2> <table cellspacing="1" cellpadding="0" class="program"> <tbody><tr> <th></th> <th>Grade</th> <th>Name</th> <th>Location</th> <th>Days</th> <th>Price</th> </tr> <tr class="v"><td><input type="radio" id="b" value="2" name="b" onclick="showData(this.value)" ></td><td>4</td><td>name of item 2</td><td>location2</td><td>4</td><td class="price1">200</td></tr><tr class="v"><td ><input type="radio" id="c" value="3" name="b" onclick="showData(this.value)"></td><td>5</td><td>name of item 3</td><td>location3</td><td>8</td><td class="price1">150</td></tr> </tbody> </table> <div style="margin-top:50px; border:5px solid red; padding:10px;"><input name="sumFromAjax" type="text" value="0" id="total" /></div> </body> Javascript <script type="text/javascript"> var isClicked = false; function showData(str) { isClicked = !isClicked; var didHeClick = isClicked ? '1' : '0'; //alert(didHeClick); var url = "getData.php"; var params = "q="+str+"&clk="+didHeClick; 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) { var isClicked = false; var x = document.getElementById("total").value; document.getElementById("total").value=parseInt(xmlhttp.responseText) + parseInt(x); } } xmlhttp.open("GET",url+"?"+params,true); xmlhttp.send(); } </script> PHP code <?php $q=$_GET["q"]; $clicked=$_GET["clk"]; if($q==1){ if($clicked){ $x=100; } else { $x=-100;} } elseif($q==2){ if($clicked){ $x=200; } else { $x=-200;} } elseif($q==3){ if($clicked){ $x=150; } else { $x=-150;} } else { $x=0; } echo $x; ?>
  2. Hey guys, I have a flash movie which resides in a folder named ‘gallery’ in the root directory. When the page is loaded, it is unable to load the xml file, but the movie loads fine. Both the xml file and the movie are located within the ‘gallery’ folder. I am assuming it has something to do with the .htaccess file While checking through firebug GET gallery.xml http://localhost/adv/activities/gallery.xml Here’s what my .htaccess file currently looks like: RewriteEngine on RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/ RewriteRule ^(([^/]+/)*)index\.php$ http://localhost/adv/$1 [R=301,L] RewriteRule activities/(.*) activity.php?actid=$1 [L] Any help, please.
  3. Yes I have done that this is my actual code if(isset($_REQUEST['brand'])) { $sSqlQuery = 'where published=?'; $row = $tobj->find_all($sSqlQuery,array('Y')); if($tobj->_row_count>0) { foreach($row as $r) { $brand = explode(',',$r->brand_id); $myTotalBrand=count($brand); if(in_array($cat_id,$brand)) { //echo $myTotalBrand; if ($myTotalBrand==1) { echo "<div style='text-align:center; height:100px; margin-top:50px;'><img src='".SITE_URL."/images/loading10.gif' /><div>loading...</div></div>"; echo "<script>document.location.href='".SITE_URL."/shop/".$r->slug."'</script>"; } else { $count_check++; if(($count_check%6)==0) { echo '<li style="margin-right:0px;">'; } else echo '<li>'; echo "<a href='".SITE_URL."/shop/".$r->slug."'>";echo "<img src=\"$r->logo_img\">"; echo "</a>"; echo "<a href='".SITE_URL."/shop/".$r->slug."' class='fixht'>"; echo ucfirst($r->shop_title); echo "</a>"; echo '</li>'; } } // end in array check } } // end row count }
  4. Hi, Code <?php $a = '20,44,72,73'; $b = explode(',', $a); $total = count($b); $c = 20; $d = in_array($c, $b); if ($d) { if ($total==1) { echo 'There is only 1 record and will be redirected to (its) detail page.';} else { echo "There are more than 1 record";} } ?> What I am trying to do is, if there is only 1 value in $a, do something if there is more than 1 value in $a do something else $a comes from a table field (this is the category id and is saved seperated with comma) This code works if the value of $a = 20 (or any other single number) It does not work if $a has more values seperated with comma. Can anyone help me please.
  5. kirupa.com/forum/ and actionscript.org
  6. Keep your header and nav inside a wrapper, set a fixed width for the wrapper and center it using margin:0 auto
  7. Thanks, I am new to this mod_rewrite (it is like a nightmare). I will check some tutorials first. anyway thanks for replying
  8. Well, I am total new to mod_rewrite and can't grasp the basic. I am trying to convert my url from http://localhost/mysite/activity.php?c_id=1&a_id=28 to http://localhost/mysite/activity/components/articles this is my htaccess code Options +FollowSymLinks RewriteEngine On RewriteRule ([a-zA-z])+/([a-zA-z])\.html$ activity.php?c_id=$1&a_id=$2 It is not working, can anyone tell me what I am doing wrong. Thanks
  9. I didn't tell you to add that, wat I was trying to say is you main div (main_container) is set to display:none. I think some JS is hiding your main div.
  10. <div class="main_container" style="display: none;"> Check with firebug
  11. Too much green. Are you going green ?
  12. You can do like this css .myButton { width:100px; height:25px; text-align:center; font-size:12px; text-decoration:none; line-height:25px; display:block; background-color:grey; color:#000; border:1px solid black;} html <li><a href="resume.html" class="myButton">Resume</a></li>
  13. n000bie

    Submit Code

    What should happen after you click the submit button (save the data or display it on the page) ?
  14. If the width and height is fixed you can use a single background image. Why you need to slice it in different pieces (curious)?
  15. JavaScript is case sensitive so changeStyle and ChangeStyle is different.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.