/    Sign up×
Community /Pin to ProfileBookmark

disable and enable drop down windows that insert data to mysql?

I am working on a module for my website. the module is to allow people to create groups and invite people to them.
I am currently working on the visual aspect of how the group tags will be selected
there is a text field for the name and multiple drop down lists for inserting image entries into the database.

I want to make a button for disabling and enabling different drop down windows.
My problem is I already have an id for the drop down menu so it will insert the values to mysql
But i need another id from what I can see for each drop list to be able to specify one to disable or enable.

Is there a way I can disable and enable different drop down windows that already have an id, which I need to keep?
I can’t just rename to the other ID, because I need multiple ids for each drop down so I can disable them when needed.

HERE IS MY CODE FOR THE MODULE:

[code=php]<html>
<head>
<script type=”text/javascript”>
function makeDisable(){
var x=document.getElementById(“tag_border”)
x.black_border_tech.disabled=true;
}
function makeEnable(){
var x=document.getElementById(“tag_border”)
x.black_border_tech.disabled=false;
}
</script>
<?php

class module extends forum
{
public function view()

{
global $logon;

if($logon->online) {

$q = mysql_query(“SELECT group_id FROM gamezove_deciet.account_info WHERE user = ‘”.$logon->username.”‘”, $this->c);
$r = mysql_fetch_assoc($q);

$groupquery = mysql_query(“SELECT * FROM gamezove_deciet.groups WHERE `leader_name`='” . $logon->username . “‘”, $this->c);
$groupreturn = mysql_fetch_assoc($groupquery);
//group variables
$groupname = $groupreturn[‘name’];
$groupbg = $groupreturn[‘bg’];
$groupborder = $groupreturn[‘border’];
$groupdecal = $groupreturn[‘decal’];
//group id from account_info table
$group = $r [‘group_id’];

if (!empty($group))
{

$groups = ‘<div class=”stacking” style=”margin-left: -9px;”>
<img src=”images/tags/’ .$groupbg. ‘”style=”margin-right: -165px;”/>
<img src=”images/tags/’ .$groupborder. ‘”style=”margin-top: -90px;”/>
<img src=”images/tags/’ .$groupdecal. ‘”style=”margin-top: -100px; margin-left: -165px; margin-top:100;”/>
<center><div class = “stacking” style=” margin-bottom:25px; margin-top:-65px; font-weight: bold; color:white; font-size:13px; text-shadow:

-1px -1px 0 #000,
1px -1px 0 #000,
-1px 1px 0 #000,
1px 1px 0 #000;
margin-bottom: 25px;”>
‘ . @$groupname. ‘
</div></center>’;
}
$out = ‘<div class=”right_box”>
<div class=”right_box_top” id=”headline”>Group Settings</div>
<div class=”right_box_body” id=”forum_spot”>
<table class=”table” width=”550px” id=”register”>
<tr>
<td style=”padding-left:20px;”>Tag Preview:</td>
<td>
‘ . @$groups. ‘
</td>
</tr>
‘;

if (empty($group))
{
$out .= ‘</table><br><center>
<input type=”button” value=”Save Tag” onClick=”saveTagSettings()” />
</center><br /><br /><div id=”ajax_spot” style=”text-align:center;”></div>
<input type=”text” id=”tag_name” value=”” maxlength=”15″/><div>
Background Color:<select id=”tag_bg”>
<option>Choose Color</option>
<option value=”BG_Black.png”>Black</option>
<option value=”BG_DBlue.png”>Dark Blue</option>
<option value=”BG_LBlue.png”>Light Blue</option>
<option value=”BG_Green.png”>Green</option>
<option value=”BG_Orange.png”>Orange</option>
<option value=”BG_Pink.png”>Pink</option>
<option value=”BG_Purple.png”>Purple</option>
<option value=”BG_Red.png”>Red</option>
<option value=”BG_Yellow.png”>Yellow</option>

</select>
</div>
<div class=”clear”></div>
</div>
</div>’;
}

if (!empty($group))
{
$out .= ‘</table><br><center>
<input type=”button” value=”Update Tag” onClick=”updateTagSettings()” />
</center><br /><br /><div id=”ajax_spot” style=”text-align:center;”></div>
<center><input type=”text” id=”tag_name” value=”‘ . @$groupreturn[‘name’] . ‘” maxlength=”15″/><div>
Background:<select id=”tag_bg”>
<option>Choose Color</option>
<option value=”BG_Black.png”>Black</option>
<option value=”BG_DBlue.png”>Dark Blue</option>
<option value=”BG_LBlue.png”>Light Blue</option>
<option value=”BG_Green.png”>Green</option>
<option value=”BG_Orange.png”>Orange</option>
<option value=”BG_Pink.png”>Pink</option>
<option value=”BG_Purple.png”>Purple</option>
<option value=”BG_Red.png”>Red</option>
<option value=”BG_Yellow.png”>Yellow</option>

</select>
</div>
<div>
Border:

<select>
<option id = “black_border_tech” value=”BG_Black.png”>Black</option>
<option value=”BG_DBlue.png”>Dark Blue</option>
<option value=”BG_LBlue.png”>Light Blue</option>
<option value=”BG_Green.png”>Green</option>
<option value=”BG_Orange.png”>Orange</option>
<option value=”BG_Pink.png”>Pink</option>
<option value=”BG_Purple.png”>Purple</option>
<option value=”BG_Red.png”>Red</option>
<option value=”BG_Yellow.png”>Yellow</option>

</select>
<input type=”button” onclick=”makeDisable()” value=”Disable list”>
<input type=”button” onclick=”makeEnable()” value=”Enable list”>
</div>
</center>
<div class=”clear”></div>

</div>
</div>’;
}
return $out;
}
}
}

?>[/code]

HERE IS THE CODE FOR MY FORUM WHICH IT IS EXTENDING: I only put the part that was relevant

[code=php]
function saveTagValues() {
global $logon;

if ($logon->online) {
$tag_name= mysql_real_escape_string($_POST[‘tagname’]);
$tag_bg= mysql_real_escape_string($_POST[‘tagbg’]);
$tag_border= mysql_real_escape_string($_POST[‘tagborder’]);
$tag_decal= mysql_real_escape_string($_POST[‘tagdecal’]);

if (strlen($tag_name) > 15) {
die(“tag may not exceed 15 characters.”);
}
if (strlen($tag_name) < 1) {
die(“tag name can not be blank!”);
}

mysql_query(“INSERT INTO ” . $this->db . “.groups(`leader_name`, `name`, `bg`, `border`, `decal`) VALUES(‘” . $logon->username . “‘, ‘” . $tag_name . “‘, ‘” . $tag_bg . “‘, ‘” . $tag_border . “‘, ‘” . $tag_decal . “‘)”, $this->c) or die(“Something went wrong, please try again, or contact an admin”);
$groupquery = mysql_query(“SELECT * FROM gamezove_deciet.groups WHERE `leader_name`='” . $logon->username . “‘”, $this->c);
$groupreturn = mysql_fetch_assoc($groupquery);
$group = $groupreturn [‘id’];

mysql_query(“UPDATE gamezove_deciet.account_info SET group_id = ‘” . $group . “‘ WHERE `user`='” . $logon->username . “‘”, $this->c) or die(“Its being gay again”);

echo “Your tag have been saved!”;

}
}
function updateTagValues() {
global $logon;

$tag_name= mysql_real_escape_string($_POST[‘tagname’]);
$tag_bg= mysql_real_escape_string($_POST[‘tagbg’]);
$tag_border= mysql_real_escape_string($_POST[‘tagborder’]);
$tag_decal= mysql_real_escape_string($_POST[‘tagdecal’]);

mysql_query(“UPDATE gamezove_deciet.groups SET leader_name = ‘” . $logon->username . “‘, name='” . $tag_name . “‘, bg='” . $tag_bg . “‘, border='” . $tag_border . “‘, decal='” . $tag_decal . “‘ WHERE `leader_name`='” . $logon->username . “‘”, $this->c) or die(“Something went wrong, please try again!”);

if (strlen($password) > 0)
{

echo “Your tag have been updated!”;

if(strlen($password) > 0)
{
$logon->logout();
}

}
}
[/code]

AND HERE IS MY JS FILE, I once again only put in the relevant part

[code=php]function saveTagSettings() {
var tagname = $(“#tag_name”).val()
var tagbg = $(“#tag_bg”).val()
var tagborder = $(“#tag_border”).val()
var tagdecal = $(“#tag_decal”).val()
$(“#ajax_spot”).html(“<img src=’theme/” + theme + “/images/ajax.gif’ />”)

$.post(“inc/forum_ajax.php”, { ajax: 19, tagname: tagname, tagbg: tagbg, tagborder: tagborder, tagdecal: tagdecal}, function(data) {
$(“#ajax_spot”).html(data)
});

}
function updateTagSettings() {
var tagname = $(“#tag_name”).val()
var tagbg = $(“#tag_bg”).val()
var tagborder = $(“#tag_border”).val()
var tagdecal = $(“#tag_decal”).val()
$(“#ajax_spot”).html(“<img src=’theme/” + theme + “/images/ajax.gif’ />”)

$.post(“inc/forum_ajax.php”, { ajax: 20, tagname: tagname, tagbg: tagbg, tagborder: tagborder, tagdecal: tagdecal}, function(data) {
$(“#ajax_spot”).html(data)
});

}[/code]

any help would be appreciated

to post a comment
Full-stack Developer

2 Comments(s)

Copy linkTweet thisAlerts:
@SerifazauthorMay 21.2015 — Just an update. I think I want to get element by class but not sure how to do it? any tips?

just anything besides get elementbyid would be great honestly
Copy linkTweet thisAlerts:
@SerifazauthorMay 22.2015 — ok so I figured out the problem I needed to know how the getelementsbyclassname was for arrays.

so I got that working. but I have one last question. how would I keep my values that are disabled from inserting to mysql.
×

Success!

Help @Serifaz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...