Jump to content

A little Javascript problem


selenin

Recommended Posts

Hello, I just try to modify a script and I have this problem

 

My Javascript code:

 

<script type="text/javascript">

jQuery(document).ready(

  function() {

catlist();

  });

 

  $(document).ready(function(){

  $("#pm_sources").change(function () {

  var str = $("select option:selected").attr('value');

  $("#pm_sources_ex").text(str);

  })

  .change();

  });

 

</script>

 

My Template Code:

 

			<select name="category" size="1" >
		<option value="-1">{$lang.select}</option>
			{foreach from=$categories_list key=k item=v}
			<option value="{$k}" {if $smarty.post.category == $k}selected{/if}>{$v}</option>
			{/foreach}
		</select>



		<select name="" id="pm_sources" size="1" >
			<option selected="selected">{$lang.select}</option>
			{foreach from=$sources key=k item=v}
			  <option value="{$v.url_example}">{$v.source_name|capitalize}</option>
			{/foreach}
		</select>
		<input type="text" name="yt_id" value="{$smarty.post.yt_id}" size="60" class="inputtext" />
		 <br /><small>Example: <span id="pm_sources_ex"></span></small>

 

My problem is when I put pm_sources before the category it works fine, but like I want to have it like this order it takes for pm_sources_ex the -1 from categories  :shrug:

Link to comment
Share on other sites

No problem. I was also able to get it to work using what I told you try in my first reply.

 

<html>
<head>
<title>Select Test</title>
<script src="jquery-1.4.2.min.js"></script>
<script>
$(document).ready(function() {
$('#firstSelect').change(function() {
	alert($(this).val());
});

$('#secondSelect').change(function() {
	alert($(this).val());
});
});
</script>
</head>
<body>
<select id="firstSelect">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select id="secondSelect">
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.