Jump to content
View in the app

A better way to browse. Learn more.

The Uniform Server Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Using Li element for get/post

Featured Replies

I found this at w3 schools PHP tutorial but see it represents a Select html box and options and my site has UL, List/Li Elements that had < a tags with href and target attributes. I've stripped the jewelry UL of it's Li

< a tags and want to know how to get the Li oncklick to get the database table to change the 'f1' div innerHTML.

w3 School

http://www.w3schools.com/php/php_ajax_database.asp

The function

function showUser(str)
{
if (str=="")
 {
 document.getElementById("txtHint").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("txtHint").innerHTML=xmlhttp.responseText;
}
 }
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}

 

I have addEvent in mockup.js like so

var jewelrylist=document.getElementById('jewelrylist');
var jewelry=jewelrylist.getElementsByTagName('li');
var silver=jewelry.item(1);
function getsilver(text)//Changed from 'str'
{
if (silver.text=="Silver")//the li element text
 {
 document.getElementById("f1").innerHTML="";//the div id I want to change
 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("f1").innerHTML=xmlhttp.responseText;
}
 }
xmlhttp.open("GET","getSilver.php?s="+str,true);//don't know if this file goes in the www folder?
xmlhttp.send();
}
addEvent(silver,'click', getsilver(); }, false);//Should work??  

:rolleyes:

My HTML UL ID jewelrylist

<ul id="jewelrylist">
<li id="jewelry" class="top" title="The Most Beautiful Jewelry Made in Mexico!">Jewelry</li>
<li class="item" title="Silver Jewelry Made in Mexico!">Silver</li>
<li class="item" title="Silver & Gold Jewelry, Made in Mexico!">Silver & Gold</li>
<li class="item" title="Silver Jewelry with Stones, Made in Mexico!">Silver & Stones</a>
</li>
</ul>

getSilver.php Not sure what folder to put this in, www or php?

<?php
$s=$_GET["s"];
$con=mysql_connectmysql_connect('localhost','root','root');//default for Uniserver??
if(!con){die('Not connected:'.mysql_error( ));}
mysql_select_db("wbi",$con);//mydb
$sql="SELECT*FROM silver WHERE Id='".$s."'";//table silver has 2 test rows
$result=mysql_query($sql);
while($row = mysql_fetch_array($result))//might have to add some splits for Set types in rows?
{
echo "<div id='rowcell" . $row['Id'] . "' class='rowcell'>";
echo "<div id='imagecell" . $row['Id'] . "' class='imagecell' align='center'>";
echo "<a id='imageref" . $row['Id'] . "' class='imageref'"; echo "href='" . $row['Href'] . "' title='Take a Closer Look then Press Your"; 
echo "Back Button to Return'><img src='" . $row['Src'] . "'/></a></div>";

#end of .imagecell continues verbosley

I know I'll have to use INCLUDE mydb.php and filtering to make it more secure but I'd like to get it tried before I start modifying the other ULs. Any advise greatly appreciated. Also let me know if this is an inappropriate forum for this topic :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.