Скрипт не заполняет скрытые поля

Все вопросы касающиеся использования
программы можно задать здесь
Ответить
sx000
Сообщения: 12
Зарегистрирован: 08 сен 2009, 17:15

Скрипт не заполняет скрытые поля

Сообщение sx000 » 02 мар 2010, 23:50

Внутри админки управления Wordpress есть много подводных каменй, мне надо например кое что автоматизировать, но наступил на грабли, хуман не заполняет скрытые поля. Как это пройти?

Код: Выделить всё


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>WordPress</title>
<script type="text/javascript">
//<![CDATA[
addLoadEvent = function(func) {if (typeof jQuery != "undefined") jQuery(document).ready(func); else if (typeof wpOnload!='function'){wpOnload=func;} else {var oldonload=wpOnload; wpOnload=function(){oldonload();func();}}};
//]]>
</script>
<style type="text/css">* html { overflow-x: hidden; }</style>
<link rel='stylesheet' href='http://xxx.xxx.com/wp-admin/css/global.css?ver=2.6.2' type='text/css' media='all' />
<link rel='stylesheet' href='http://xxx.xxx.com/wp-admin/wp-admin.css?ver=2.6.2' type='text/css' media='all' />
<link rel='stylesheet' href='http://xxx.xxx.com/wp-admin/css/colors-fresh.css?ver=2.6.2' type='text/css' media='all' />
<!--[if gte IE 6]>
<link rel='stylesheet' href='http://xxx.xxx.com/wp-admin/css/ie.css?ver=2.6.2' type='text/css' media='all' />
<![endif]-->
<script type='text/javascript' src='http://xxx.xxx.com/wp-includes/js/jquery/jquery.js?ver=1.2.6'></script>
<script type='text/javascript' src='http://xxx.xxx.com/wp-admin/js/common.js?ver=20080318'></script>
<script type='text/javascript' src='http://xxx.xxx.com/wp-includes/js/jquery/jquery.color.js?ver=2.0-4561'></script>
<script type='text/javascript' src='http://xxx.xxx.com/wp-admin/js/blog-switch.js?ver=2'></script>
<script type='text/javascript'>
/* <![CDATA[ */
	wpGearsL10n = {
		updateCompleted: "Update completed.",
		error: "Error:"
	}
/* ]]> */
</script>
<script type='text/javascript' src='http://xxx.xxx.com/wp-admin/js/wp-gears.js?ver=20080721'></script>
<link rel='stylesheet' href='http://xxx.xxx.com/wp-admin/css/mu.css?version=2.6.2' type='text/css' />
<script type="text/javascript" src="../wp-includes/js/colorpicker.js"></script>
<script type='text/javascript'>
// <![CDATA[
	function pickColor(color) {
		ColorPicker_targetInput.value = color;
		kUpdate(ColorPicker_targetInput.id);
	}
	function PopupWindow_populate(contents) {
		contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" class="button-secondary" value="Close Color Picker" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';
		this.contents = contents;
		this.populated = false;
	}
	function PopupWindow_hidePopup(magicword) {
		if ( magicword != 'prettyplease' )
			return false;
		if (this.divName != null) {
			if (this.use_gebi) {
				document.getElementById(this.divName).style.visibility = "hidden";
			}
			else if (this.use_css) {
				document.all[this.divName].style.visibility = "hidden";
			}
			else if (this.use_layers) {
				document.layers[this.divName].visibility = "hidden";
			}
		}
		else {
			if (this.popupWindow && !this.popupWindow.closed) {
				this.popupWindow.close();
				this.popupWindow = null;
			}
		}
		return false;
	}
	function colorSelect(t,p) {
		if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" )
			cp.hidePopup('prettyplease');
		else {
			cp.p = p;
			cp.select(t,p);
		}
	}
	function PopupWindow_setSize(width,height) {
		this.width = 162;
		this.height = 210;
	}

	var cp = new ColorPicker();
	function advUpdate(val, obj) {
		document.getElementById(obj).value = val;
		kUpdate(obj);
	}
	function kUpdate(oid) {
		if ( 'uppercolor' == oid || 'lowercolor' == oid ) {
			uc = document.getElementById('uppercolor').value.replace('#', '');
			lc = document.getElementById('lowercolor').value.replace('#', '');
			hi = document.getElementById('headerimage');
			hi.value = 'header-img.php?upper='+uc+'&lower='+lc;
			document.getElementById('header').style.background = 'url("http://xxx.xxx.com/wp-content/themes/default/images/'+hi.value+'") center no-repeat';
			document.getElementById('advuppercolor').value = '#'+uc;
			document.getElementById('advlowercolor').value = '#'+lc;
		}
		if ( 'fontcolor' == oid ) {
			document.getElementById('header').style.color = document.getElementById('fontcolor').value;
			document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value;
		}
		if ( 'fontdisplay' == oid ) {
			document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
		}
	}
	function toggleDisplay() {
		td = document.getElementById('fontdisplay');
		td.value = ( td.value == 'none' ) ? 'inline' : 'none';
		kUpdate('fontdisplay');
	}
	function toggleAdvanced() {
		a = document.getElementById('jsAdvanced');
		if ( a.style.display == 'none' )
			a.style.display = 'block';
		else
			a.style.display = 'none';
	}
	function kDefaults() {
		document.getElementById('headerimage').value = '';
		document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#69aee7';
		document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#4180b6';
		document.getElementById('header').style.background = 'url("http://xxx.xxx.com/wp-content/themes/default/images/kubrickheader.jpg") center no-repeat';
		document.getElementById('header').style.color = '#FFFFFF';
		document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '';
		document.getElementById('fontdisplay').value = 'inline';
		document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
	}
	function kRevert() {
		document.getElementById('headerimage').value = 'header-img.php?upper=69aee7&lower=4180b6';
		document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#69aee7';
		document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#4180b6';
		document.getElementById('header').style.background = 'url("http://xxx.xxx.com/wp-content/themes/default/images/header-img.php?upper=69aee7&lower=4180b6") center no-repeat';
		document.getElementById('header').style.color = '';
		document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = 'white';
		document.getElementById('fontdisplay').value = 'inline';
		document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
	}
	function kInit() {
		document.getElementById('jsForm').style.display = 'block';
		document.getElementById('nonJsForm').style.display = 'none';
	}
	addLoadEvent(kInit);
// ]]>
</script>
<style type='text/css'>
	#headwrap {
		text-align: center;
	}
	#kubrick-header {
		font-size: 80%;
	}
	#kubrick-header .hibrowser {
		width: 780px;
		height: 260px;
		overflow: scroll;
	}
	#kubrick-header #hitarget {
		display: none;
	}
	#kubrick-header #header h1 {
		font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
		font-weight: bold;
		font-size: 4em;
		text-align: center;
		padding-top: 70px;
		margin: 0;
	}

	#kubrick-header #header .description {
		font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
		font-size: 1.2em;
		text-align: center;
	}
	#kubrick-header #header {
		text-decoration: none;
		color: white;
		padding: 0;
		margin: 0;
		height: 200px;
		text-align: center;
		background: url('http://xxx.xxx.com/wp-content/themes/default/images/header-img.php?upper=69aee7&lower=4180b6') center no-repeat;
	}
	#kubrick-header #headerimg {
		margin: 0;
		height: 200px;
		width: 100%;
		display: inline;
	}
	#jsForm {
		display: none;
		text-align: center;
	}
	#jsForm input.submit, #jsForm input.button, #jsAdvanced input.button {
		padding: 0px;
		margin: 0px;
	}
	#advanced {
		text-align: center;
		width: 620px;
	}
	html>body #advanced {
		text-align: center;
		position: relative;
		left: 50%;
		margin-left: -380px;
	}
	#jsAdvanced {
		text-align: right;
	}
	#nonJsForm {
		position: relative;
		text-align: left;
		margin-left: -370px;
		left: 50%;
	}
	#nonJsForm label {
		padding-top: 6px;
		padding-right: 5px;
		float: left;
		width: 100px;
		text-align: right;
	}
	.defbutton {
		font-weight: bold;
	}
	.zerosize {
		width: 0px;
		height: 0px;
		overflow: hidden;
	}
	#colorPickerDiv a, #colorPickerDiv a:hover {
		padding: 1px;
		text-decoration: none;
		border-bottom: 0px;
	}
</style>
</head>
<body class="wp-admin ">
<div id="wpwrap">
<div id="wpcontent">
<div id="wphead">
<h1>Title<span id="viewsite"><a href="http://xxx.xxx.com/">Visit Site</a></span></h1>
</div>

	<div id="gears-info-box" class="info-box" style="display:none;">
	<img src="images/gear.png" title="Gear" alt="" class="gears-img" />
	<div id="gears-msg1">
	<h3 class="info-box-title">Speed up WordPress</h3>
	<p>WordPress now has support for Gears, which adds new features to your web browser.<br />
	<a href="http://gears.google.com/" target="_blank" style="font-weight:normal;">More information...</a></p>
	<p>After you install and enable Gears most of WordPress’ images, scripts, and CSS files will be stored locally on your computer. This speeds up page load time.</p>
	<p><strong>Don’t install on a public or shared computer.</strong></p>	<div class="submit"><button onclick="window.location = 'http://gears.google.com/?action=install&return=http%3A%2F%2Fxxx.xxx.com%2Fwp-admin%2F';" class="button">Install Now</button>
	<button class="button" style="margin-left:10px;" onclick="document.getElementById('gears-info-box').style.display='none';">Cancel</button></div>
	</div>

	<div id="gears-msg2" style="display:none;">
	<h3 class="info-box-title">Gears Status</h3>
	<p>Gears is installed on this computer but is not enabled for use with WordPress.</p> 
	<p>To enable it, make sure this web site is not on the denied list in Gears Settings under your browser Tools menu, then click the button below.</p>
	<p><strong>However if this is a public or shared computer, Gears should not be enabled.</strong></p>
	<div class="submit"><button class="button" onclick="wpGears.getPermission();">Enable Gears</button>
	<button class="button" style="margin-left:10px;" onclick="document.getElementById('gears-info-box').style.display='none';">Cancel</button></div>
	</div>

	<div id="gears-msg3" style="display:none;">
	<h3 class="info-box-title">Gears Status</h3>
	<p>Gears is installed and enabled on this computer. You can disable it from your browser Tools menu.</p>
	<p>If there are any errors, try disabling Gears, then reload the page and enable it again.</p>
	<p>Local storage status: <span id="gears-wait"><span style="color:#f00;">Please wait! Updating files:</span> <span id="gears-upd-number"></span></span></p>
	<div class="submit"><button class="button" onclick="document.getElementById('gears-info-box').style.display='none';">Close</button></div>
	</div>
	</div>

<div id="user_info"><p>Howdy, <a href="profile.php">gogport</a>! | <a href="http://xxx.xxx.com/wp-login.php?action=logout" title="Log Out">Log Out</a> | <a href="http://codex.wordpress.org/">Help</a> | <a href="http://wordpress.org/support/">Forums</a> | <span id="gears-menu"><a href="#" onclick="wpGears.message(1);return false;">Turbo</a></span></p></div>


<ul id="dashmenu">
	<li><a href='http://xxx.xxx.com/wp-admin/' class="current">Ttile</a></li>
	<li id="all-my-blogs-tab" class="wp-no-js-hidden"><a href="#" class="blog-picker-toggle">All my blogs</a></li>

	</ul>

	<form id="all-my-blogs" action="" method="get" style="display: none">
		<p>
			Choose a blog: 
		<select>
			
			<option value='http://xxx.xxx.com/wp-admin/'>xxx</option>
		</select>
			<input type="submit" class="button" value="Go" />
			<a href="#" class="blog-picker-toggle">Cancel</a>
		</p>
	</form>



<ul id="adminmenu">

	<li><a href='post-new.php'>Write</a></li>
	<li><a href='edit.php'>Manage</a></li>
	<li><a href='themes.php' class="current">Design</a></li>
	<li><a href='edit-comments.php'>Comments <span id='awaiting-mod' class='count-0'><span class='comment-count'>0</span></span></a></li></ul>

<ul id="sidemenu">

	<li><a href='options-general.php'>Settings</a> </li>
	<li><a href='plugins.php'>Plugins <span id='update-plugins' class='count-2'><span class='plugin-count'>2</span></span></a> </li>
	<li><a href='users.php'>Users</a></li></ul>


<ul id="submenu">

	<li><a href='themes.php'>Themes</a></li>
	<li><a href='widgets.php'>Widgets</a></li>
	<li><a href='themes.php?page=functions.php' class="current">Header Image and Color</a></li>
</ul>
<div id="wpbody">
<div id="message" class="updated fade"><p><strong>Options saved.</strong></p></div><div class='wrap'>
	<div id="kubrick-header">
	<h2>Header Image and Color</h2>
		<div id="headwrap">
			<div id="header">
				<div id="headerimg">
					<h1>Title</h1>
					<div class="description"></div>
				</div>
			</div>
		</div>
		<br />
		<div id="nonJsForm">
			<form method="post" action="">
				<input type="hidden" id="_wpnonce" name="_wpnonce" value="f163789fbe" /><input type="hidden" name="_wp_http_referer" value="/wp-admin/themes.php?page=functions.php&saved=true" />				<div class="zerosize"><input type="submit" name="defaultsubmit" value="Save" /></div>
					<label for="njfontcolor">Font Color:</label><input type="text" name="njfontcolor" id="njfontcolor" value="" /> Any CSS color (<code>red</code> or <code>#FF0000</code> or <code>rgb(255, 0, 0)</code>)<br />
					<label for="njuppercolor">Upper Color:</label><input type="text" name="njuppercolor" id="njuppercolor" value="#69aee7" /> HEX only (<code>#FF0000</code> or <code>#F00</code>)<br />
				<label for="njlowercolor">Lower Color:</label><input type="text" name="njlowercolor" id="njlowercolor" value="#4180b6" /> HEX only (<code>#FF0000</code> or <code>#F00</code>)<br />
				<input type="hidden" name="hi" id="hi" value="header-img.php?upper=69aee7&lower=4180b6" />
				<input type="submit" name="toggledisplay" id="toggledisplay" value="Toggle Text" />
				<input type="submit" name="defaults" value="Use Defaults" />
				<input type="submit" class="defbutton" name="submitform" value="&nbsp;&nbsp;Save&nbsp;&nbsp;" />
				<input type="hidden" name="action" value="save" />
				<input type="hidden" name="njform" value="true" />
			</form>
		</div>
		<div id="jsForm">
			<form style="display:inline;" method="post" name="hicolor" id="hicolor" action="/wp-admin/themes.php?page=functions.php&saved=true">
				<input type="hidden" id="_wpnonce" name="_wpnonce" value="f163789fbe" /><input type="hidden" name="_wp_http_referer" value="/wp-admin/themes.php?page=functions.php&saved=true" />	<input type="button"  class="button-secondary" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="Font Color"></input>
		<input type="button" class="button-secondary" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="Upper Color"></input>
		<input type="button" class="button-secondary" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="Lower Color"></input>
				<input type="button" class="button-secondary" name="revert" value="Revert" onclick="kRevert()" />
				<input type="button" class="button-secondary" value="Advanced" onclick="toggleAdvanced()" />
				<input type="hidden" name="action" value="save" />
				<input type="hidden" name="fontdisplay" id="fontdisplay" value="" />
				<input type="hidden" name="fontcolor" id="fontcolor" value="" />
				<input type="hidden" name="uppercolor" id="uppercolor" value="69aee7" />
				<input type="hidden" name="lowercolor" id="lowercolor" value="4180b6" />
				<input type="hidden" name="headerimage" id="headerimage" value="header-img.php?upper=69aee7&lower=4180b6" />
				<p class="submit"><input type="submit" name="submitform" class="defbutton" value="Update Header" onclick="cp.hidePopup('prettyplease')" /></p>
			</form>
			<div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
			<div id="advanced">
				<form id="jsAdvanced" style="display:none;" action="">
					<input type="hidden" id="_wpnonce" name="_wpnonce" value="f163789fbe" /><input type="hidden" name="_wp_http_referer" value="/wp-admin/themes.php?page=functions.php&saved=true" />					<label for="advfontcolor">Font Color (CSS): </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="" /><br />
					<label for="advuppercolor">Upper Color (HEX): </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#69aee7" /><br />
					<label for="advlowercolor">Lower Color (HEX): </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#4180b6" /><br />
					<input type="button" class="button-secondary" name="default" value="Select Default Colors" onclick="kDefaults()" /><br />
					<input type="button" class="button-secondary" onclick="toggleDisplay();return false;" name="pick" id="pick" value="Toggle Text Display"></input><br />
				</form>
			</div>
		</div>
	</div>
</div>
</div><!-- wpbody -->
</div><!-- wpcontent -->
</div><!-- wpwrap -->
<div id="footer">
<p>
		<span id="bh" class="alignright"><a href="http://xxx.com/" title="WordPress recommends a better browser"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></span>
		Thank you for creating with <a href="http://mu.wordpress.org/">WordPress MU</a> | <a href="http://mu.wordpress.org/docs/">Documentation</a></p>
</div>
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
</body>
</html>





Мне надо заполнить поля с номерами 4 и 5 ну так их нумерует хуман.

Код: Выделить всё

<label for="advuppercolor">Upper Color (HEX): </label><input id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#69aee7" type="text"><br>
					<label for="advlowercolor">Lower Color (HEX): </label><input id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#4180b6" type="text"><br>

Вот в частности эти поля надо заполнять

Аватара пользователя
bigfozzy
Site Admin
Сообщения: 2625
Зарегистрирован: 28 июл 2008, 17:24
Контактная информация:

Сообщение bigfozzy » 23 май 2010, 21:55

исправили вроде, а как вариант могу сказать использовать функцию webpage->set_body с переформатированием ее под себя ...

Ответить